woocommerce-quick-donation-settings.php 4.42 KB
Newer Older
Tech No Freaky's avatar
Tech No Freaky committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
<?php
class WC_Quick_Donation_Settings extends WC_Settings_Page {

    /**
     * Constructor
     */
    public function __construct() {

        $this->id    = 'wc_quick_donation';

        add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_tab' ), 50 );
        add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) );
        add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
        add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );

    }

    /**
     * Add plugin options tab
     *
     * @return array
     */
    public function add_settings_tab( $settings_tabs ) {
        $settings_tabs[$this->id] = 'WC Quick Donation';
        return $settings_tabs;
    }

    /**
     * Get sections
     *
     * @return array
     */
    public function get_sections() {

        $sections = array(
            'general'         => __( 'General Settings', $this->id )
             
        );

        return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
    }


    /**
     * Get sections
     *
     * @return array
     */
    public function get_settings( $section = null ) {
		global $wc_quick_buy;
        switch( $section ){

            case 'general' :
			case '' :
               $settings = array(
					'section_title' => array(
						'name' => 'Woocommerce Quick Donation Settings',
						'type' => 'title',
						'desc' => 'Just Call <code><strong>[wc_quick_donation]</strong></code> short code any where in your page,post,widgets or template <br/>
							To Customize the <strong>Donation Form</strong> copy the template file from <code>woocommerce-quick-donation/template/donation_form.php</code> to your <code>theme/woocommerce</code> folder.
						',
						'id' => 'wc_quick_donation_section_title'
					), 			

					'remove_cart_items' => array(
						'name' => 'Auto Remove Cart Items',
						'desc' => 'Removes Other Cart Items If Donation Aded To Cart.',
						'id' => 'wc_quick_donation_cart_remove',
						'type' => 'select', 
						'class' =>'chosen_select',
						'options' => array('false' => 'Keep All Items','true'=>'Remove All Items')
					),	
                   
                   
					'redirect' => array(
						'name' => 'Redirect User To',
						'desc' => 'After  Donation Added To Cart.',
						'id' => 'wc_quick_donation_redirect',
						'type' => 'select', 
						'class' =>'chosen_select',
						'options' => array('checkout' => 'Checkout Page','cart'=>'Cart Page','false' => 'None')
					),
                   
                   
					'payment_gateway' => array(
						'name' => 'Allowed Payment Gateway\'s',
						'desc' => 'Select Payment Gateway for donation..',
						'id' => 'wc_quick_donation_payment_gateway',
						'type' => 'multiselect', 
						'class' =>'chosen_select',
						'options' => $wc_quick_buy->get_payments_gateway()
					),
					'project_names' => array(
						'name' => 'Project Names',
						'type' => 'textarea',
						'desc' => 'Add Names By <code>,</code> Seperated ',
						'id' => 'wc_quick_donation_projects', 
						'default' => 'Project1,Project2'

					),
					'order_project_title' => array(
						'name' => 'Order Project Title',
						'type' => 'text',
						'desc' => 'Title to view in order edit page',
						'id' => 'wc_quick_donation_project_section_title', 
						'default' =>'For Project'

					),
					'order_notes_title' => array(
						'name' => 'Order Notes Title',
						'type' => 'text',
						'desc' => 'to display project name use <code>Project Name : %s</code>',
						'id' => 'wc_quick_donation_order_notes_title', 
						'default' =>'Project Name %s'

					),			 		
					'section_end' => array(
						'type' => 'sectionend',
						'id' => 'wc_settings_tab_demo_section_end'
					)
				);
            break;
            case 'email_template':
				  
            break;
            

        }

        return apply_filters( 'wc_settings_tab_'.$this->id.'_settings', $settings, $section );

    }

    /**
     * Output the settings
     */
    public function output() {
        global $current_section;
        $settings = $this->get_settings( $current_section );  
        WC_Admin_Settings::output_fields( $settings );
    }


    /**
     * Save settings
     */
    public function save() {
        global $current_section;
        $settings = $this->get_settings( $current_section );
        WC_Admin_Settings::save_fields( $settings );
    }

}

return new WC_Quick_Donation_Settings();

?>