Plugin Directory

Changeset 1676034


Ignore:
Timestamp:
06/11/2017 04:50:23 PM (9 years ago)
Author:
aheadzen
Message:

Releasing version 1.3

Location:
woocommerce-cod-advanced/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • woocommerce-cod-advanced/trunk/readme.txt

    r1375606 r1676034  
    33Tags: woocommerce, cod, cash on delivery,cod advanced, minimum amount
    44Requires at least : 3.0.0
    5 Tested up to: 4.3
    6 Stable tag: 1.0.0.0
     5Tested up to: 4.8
     6Stable tag: 1.3
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4343
    4444
     45= 1.3.0 =
     46* Bug fixes.
     47
     48
    4549= 1.0.0 =
    4650* Fresh Public Release.
    47 
    48 
    49 = 1.0.1 =
    50 * Postal/Pin code option added to display COD on checkout page.
    51  -- so you should add the pin code and matched pin code user will not display the COD on checkout page.
    52 * Exclude Product Category to hide COD if excluded category product is in your cart.
    53 
    54 
    55 = 1.0.2 =
    56 * Hide COD for maximum cart total amount - Option added.
    57 
    58 
    59 = 1.0.3 =
    60 * Country to restrict the COD.
    61 * States/Provinces to restrict the COD.
    62 * City to restrict the COD.
    63 
    64 
    65 
    66 = 1.0.4 =
    67 * Display the COD for specific countries or other countries option like (include country or exclude country).
    68 * Display the COD for specific states or other states option like (include states or exclude states).
    69 * Display the COD for specific cities or other cities option like (include cities or exclude cities).
    70 * Display the COD for specific postal code or other postal code option like (include postal code or exclude postal code).
    71 
    72 
    73 = 1.0.5 =
    74 * Checkout page - on change of country, state , city or pincode -- COD advanced plugin condition not working - Error SOLVED
    75 
    76 
    77 = 1.0.6 =
    78 * PHP syntax  - Error SOLVED
    79 
    80 
    81 = 1.0.7 =
    82 * Added New COD icon for checkout page
    83 * added option to show/hide COD icon from settings.
    84 
    85 
    86 = 1.0.8 =
    87 * Display warnings - Solved.
    88 
    89 
    90 = 1.0.9 =
    91 * New option added to disable the COD payment option for virtual or digital product selected in the cart.
    92 * Display message for COD disabled condition is applied. It will display the message as per you have inserted in the input box.
    93 
    94 
    95 = 1.0.10 =
    96 * On checkout pgae if pincode/address not match with your shopping and cod is hidden, message display.
    97 * Pincode checking problem - Solved.
    98 
    99 = 1.2.0 =
    100 * For wooCommerce version : 2.4.5, some error on address change for shipping. Now Solved.
    101 
    102 = 1.2.1 =
    103 * Added COD extra charge display for order reivew and emails.
    104 
    105 
    106 = 1.2.3 =
    107 * Added COD extra charge display for order reivew and emails.
    108 
    109 = 1.2.4 =
    110 * Added COD extra charge Message so user can change message as per they want.
    111 
    112 = 1.2.5 =
    113 * Notice: Undefined variable: zone_fields in ......... woocommerce_advanced_cod.php on line 159 -- ERROR Solved
    114 
    115 = 1.2.6 =
    116 * Localization added.
    117 
    118 = 1.2.7 =
    119 * Localization added method changed.
  • woocommerce-cod-advanced/trunk/woocommerce_advanced_cod.php

    r1375606 r1676034  
    44Plugin URI: http://aheadzen.com/
    55Description: Cash On Delivery Advanced - Added advanced options like hide COD payment while checkout if minimum amount, enable extra charges if minimum amount.
    6 Author: Aheadzen Team 
     6Author: Aheadzen Team
    77Version: 1.2.7
    88Author URI: http://aheadzen.com/
     
    2424        add_action('wp_head',array($this,'adv_cod_wp_header'), 99 );
    2525        add_filter('woocommerce_gateway_icon',array($this,'adv_cod_gateway_icon'),9,2);
    26        
     26
    2727        add_action('woocommerce_cart_calculate_fees',array( &$this, 'woo_add_extra_fee'));
    28        
     28
    2929        add_action('init',array($this,'az_woocod_init'));
    30        
     30
    3131        global $woocommerce;
    3232        if(isset($_POST['action']) && $_POST['action'] == 'woocommerce_update_order_review'){
    33             add_filter('woocommerce_available_payment_gateways',array($this,'adv_cod_filter_gateways'));   
    34         }   
     33            add_filter('woocommerce_available_payment_gateways',array($this,'adv_cod_filter_gateways'));
     34        }
    3535    }
    36    
    37    
     36
     37
    3838    function az_woocod_init(){
    3939        load_plugin_textdomain('askoracle', false, basename( dirname( __FILE__ ) ) . '/languages');
    4040    }
    41    
     41
    4242    /****************************
    4343    COD header
     
    5555    <?php
    5656    }
    57    
     57
    5858    /****************************
    5959    COD admin options
     
    6464        $allowed_countries = $woocommerce->countries->get_allowed_countries();
    6565        asort( $allowed_countries );
    66        
     66
    6767        $form_fields['cod_adv_title'] = array(
    6868                            'title'         => __('WooCommerce Advanced COD Plugin Settings','askoracle'),
     
    7070                            'default'       => 'no',
    7171                        );
    72        
     72
    7373        $form_fields['disable_cod_adv'] = array(
    7474                            'title'         => __('Disable Advanced COD?','askoracle'),
     
    7878                            'desc_tip'      => '0',
    7979                        );
    80                        
     80
    8181        $form_fields['cod_icon'] = array(
    8282                            'title'         => __('Display icon on checkout page?','askoracle'),
     
    8686                            'desc_tip'      => '0',
    8787                        );
    88                        
     88
    8989        $form_fields['min_amount'] = array(
    9090                            'title'         => __('Minimum cart amount to display','askoracle'),
     
    9494                            'desc_tip'      => '0',
    9595                        );
    96        
     96
    9797        $form_fields['max_amount'] = array(
    9898                            'title'         => __('Maximum cart amount to hide','askoracle'),
     
    102102                            'desc_tip'      => '0',
    103103                        );
    104                        
     104
    105105        $form_fields['extra_charge_min_amount'] = array(
    106106                            'title'         => __('Minimum cart amount for free COD','askoracle'),
     
    110110                            'desc_tip'      => '0',
    111111                        );
    112                        
     112
    113113        $form_fields['extra_charges'] = array(
    114114                            'title'         => __('Extra charges','askoracle'),
     
    118118                            'desc_tip'      => '0',
    119119                        );
    120                        
     120
    121121        $form_fields['extra_charges_msg'] = array(
    122122                            'title'         => __('Message for extra charges','askoracle'),
     
    126126                            'desc_tip'      => '',
    127127                        );
    128                        
     128
    129129        $form_fields['extra_charges_type'] = array(
    130130                            'title'         => __('Extra charges type','askoracle'),
     
    135135                            'options'       => array('amount'=>__('Total Add','askoracle'),'percentage'=>__('Total % Add','askoracle'))
    136136                        );
    137        
     137
    138138        $form_fields['roundup_type'] = array(
    139139                            'title'         => __('Round up total amount by','askoracle'),
     
    144144                            'options'       => array('0'=>0,'5'=>5,'10'=>10,'50'=>50,'100'=>100)
    145145                        );
    146                        
    147        
     146
     147
    148148        /**Category**/
    149149        $cat_arr = array();
     
    160160                            'options'       => $cat_arr
    161161                        );
    162        
     162
    163163        /**Country**/
    164164        $country_arr = array();
     
    185185                            'options'       => $country_arr
    186186                        );
    187        
     187
    188188        $form_fields['in_ex_country'] = array(
    189189                            'title'         => __('Country include/exclude?','askoracle'),
     
    194194                                'include' => __('Display COD if user is from above country', 'askoracle' ),
    195195                                'exclude'  => __('Hide COD if user is from above country', 'askoracle' )
    196                             ), 
    197                         );
    198        
    199 
    200         /**States**/       
     196                            ),
     197                        );
     198
     199
     200        /**States**/
    201201        $state_arr = array();
    202202        if ( $woocommerce->countries->get_allowed_country_states() ) {
     
    222222                            'options'       => $state_arr
    223223                        );
    224        
     224
    225225        $form_fields['in_ex_states'] = array(
    226226                            'title'         => __('States/Provinces include/exclude?','askoracle'),
     
    231231                                'include' => __('Display COD if user is from above state', 'askoracle' ),
    232232                                'exclude'  => __('Hide COD if user is from above state', 'askoracle' )
    233                             ), 
    234                         );
    235                        
     233                            ),
     234                        );
     235
    236236        $form_fields['city'] = array(
    237237                            'title'         => __('Enter Cities','askoracle'),
     
    241241                            'desc_tip'      => '0',
    242242                        );
    243        
     243
    244244        $form_fields['in_ex_city'] = array(
    245245                            'title'         => __('City include/exclude?','askoracle'),
     
    250250                                'include' => __('Display COD if user is from above city', 'askoracle' ),
    251251                                'exclude'  => __('Hide COD if user is from above city', 'askoracle' )
    252                             ), 
    253                         );
    254                        
     252                            ),
     253                        );
     254
    255255        $form_fields['cod_pincodes'] = array(
    256256                            'title'         => __('Postal/Pin codes to hide COD','askoracle'),
     
    260260                            'desc_tip'      => '0',
    261261                        );
    262        
     262
    263263        $form_fields['in_ex_pincode'] = array(
    264264                            'title'         => __('Postal/Pin code include/exclude?','askoracle'),
     
    269269                                'include' => __('Display COD if user is from above postal code', 'askoracle' ),
    270270                                'exclude'  => __('Hide COD if user is from above postal code', 'askoracle' )
    271                             ), 
    272                         );
    273        
     271                            ),
     272                        );
     273
    274274        $form_fields['hide_virtual_product'] = array(
    275275                            'title'         => __('Hide for virtual and downloadable products?','askoracle'),
     
    279279                            'desc_tip'      => '0',
    280280                        );
    281        
     281
    282282        $form_fields['hide_virtual_product_msg'] = array(
    283283                            'title'         => __('COD hide message','askoracle'),
     
    286286                            'default'       => '',
    287287                            'desc_tip'      => '0',
    288                         );                     
    289                        
     288                        );
     289
    290290        return $form_fields;
    291291    }
    292292
    293    
     293
    294294    /****************************
    295295    COD filter show/hide COD
     
    302302        global $wpdb,$woocommerce,$hide_virtual_product_msg;
    303303        $settings = get_option('woocommerce_cod_settings');
    304        
     304
    305305        if($settings['disable_cod_adv'] && $settings['disable_cod_adv']=='yes'){return $gateways;}
    306306        if(isset($settings) && $settings)
    307307        {
    308308            $min_cod_amount = $settings['min_amount'];
    309             $max_cod_amount = $settings['max_amount'];         
     309            $max_cod_amount = $settings['max_amount'];
    310310            $exclude_country = $settings['country'];
    311311            $in_ex_country = $settings['in_ex_country'];
     
    347347            }
    348348        }
    349        
     349
    350350        global $woocommerce;
    351351        if($_POST['action'] == 'woocommerce_update_order_review' || $_GET['wc-ajax']=='update_order_review'){
     
    354354            $customer_detail = WC()->session->get('customer');
    355355        }
    356        
     356
    357357        if($cod_enabled && $exclude_country){
    358358            if($customer_detail['s_country']){
     
    364364                unset($gateways['cod']);
    365365                $cod_enabled=0;
    366             }else           
     366            }else
    367367            if($shipping_country && $in_ex_country=='exclude' && in_array($shipping_country,$exclude_country)){
    368368                unset($gateways['cod']);
    369369                $cod_enabled=0;
    370             }           
    371         }
    372        
     370            }
     371        }
     372
    373373        if($cod_enabled && $exclude_states){
    374374            if($customer_detail['s_country'] && $customer_detail['s_state']){
     
    377377                $shipping_state = trim($customer_detail['shipping_country'].':'.$customer_detail['shipping_state']);
    378378            }
    379            
     379
    380380            if($shipping_state && $in_ex_states=='include' && !in_array($shipping_state,$exclude_states)){
    381381                unset($gateways['cod']);
     
    393393            }else{
    394394                $shipping_city = strtolower(trim($customer_detail['shipping_city']));
    395             }   
    396            
     395            }
     396
    397397            if($exclude_city_arr && $in_ex_city=='include' && !in_array($shipping_city,$exclude_city_arr)){
    398398                unset($gateways['cod']);
     
    403403            }
    404404        }
    405        
     405
    406406        if($cod_enabled && $cod_pincodes){
    407             $cod_pincodes_arr = explode(',',$cod_pincodes);     
     407            $cod_pincodes_arr = explode(',',$cod_pincodes);
    408408            if($customer_detail['s_city']){
    409409                $shipping_postcode = trim($customer_detail['s_postcode']);
     
    419419            }
    420420        }
    421        
     421
    422422        $total = $woocommerce->cart->total;
    423423        if(!$total){$total = $woocommerce->cart->cart_contents_total;}
     
    426426            $cod_enabled=0;
    427427        }
    428        
     428
    429429        if($cod_enabled && $max_cod_amount && $woocommerce->cart && $total>=$max_cod_amount){
    430430            unset($gateways['cod']);
    431431            $cod_enabled=0;
    432432        }
    433        
     433
    434434        if($hide_virtual_product=='yes'){
    435435            $the_cart_contents = $woocommerce->cart->cart_contents;
     
    445445        }
    446446        if($cod_enabled==0 && $hide_virtual_product_msg!=''){
    447            
     447
    448448            add_filter('woocommerce_update_order_review_fragments', 'woocommerce_checkout_after_order_review_filter');
    449449            if(!function_exists('woocommerce_checkout_after_order_review_filter')){
     
    455455                    return $vals;
    456456                }
    457             }       
     457            }
    458458        }
    459459        return $gateways;
    460460    }
    461    
     461
    462462    /****************************
    463463    COD ICON
     
    465465    function adv_cod_gateway_icon($icon_html,$id)
    466466    {
    467         $settings = get_option('woocommerce_cod_settings');     
     467        $settings = get_option('woocommerce_cod_settings');
    468468        $cod_icon = $settings['cod_icon'];
    469469        if($id=='cod' && $cod_icon=='yes'){
     
    473473        return $icon_html;
    474474    }
    475    
     475
    476476    /****************************
    477477    COD calculate Totals
    478478    ****************************/
    479     public function adv_cod_calculate_totals( $totals ) {       
     479    public function adv_cod_calculate_totals( $totals ) {
    480480        $available_gateways = WC()->payment_gateways->get_available_payment_gateways();
    481481        $current_gateway = WC()->session->chosen_payment_method;
     
    484484            $disable_cod_adv = $current_gateways_detail->settings['disable_cod_adv'];
    485485            if($disable_cod_adv && $disable_cod_adv=='yes'){return $totals;}
    486            
     486
    487487            $current_gateway_id = $current_gateways_detail->id;
    488488            $current_gateway_title = $current_gateways_detail->title;
     
    493493            $extra_charges_type = $current_gateways_detail->settings['extra_charges_type'];
    494494            $roundup_type = $current_gateways_detail->settings['roundup_type'];
    495            
     495
    496496            if($extra_charges && $extra_charge_min_amount>=$totals->cart_contents_total){
    497497                if($extra_charges_type=="percentage"){
     
    504504                    $extra_add = $roundup_type -($totals->cart_contents_total%$roundup_type);
    505505                    $totals->cart_contents_total = $totals->cart_contents_total+$extra_add;
    506                     $extra_charges = $extra_charges+$extra_add;                 
     506                    $extra_charges = $extra_charges+$extra_add;
    507507                }
    508508                $this->current_extra_charge_min_amount = $extra_charge_min_amount;
    509509                $this->current_gateway_title = $current_gateway_title;
    510                 $this->current_gateway_extra_charges = $extra_charges;             
     510                $this->current_gateway_extra_charges = $extra_charges;
    511511                $this->current_gateway_extra_charges_type_value = $extra_charges_type;
    512512                add_action( 'woocommerce_review_order_before_order_total',  array( $this, 'adv_cod_add_payment_gateway_extra_charges_row'));
     
    517517        return $totals;
    518518    }
    519    
     519
    520520    /****************************
    521521    COD extra charge
     
    533533     <?php
    534534    }
    535    
     535
    536536    public function woo_add_extra_fee() {
    537537        global $woocommerce;
     
    540540        if($current_gateway=='cod'){
    541541            $current_gateways_detail = $available_gateways[$current_gateway];
    542            
     542
    543543            $disable_cod_adv = $current_gateways_detail->settings['disable_cod_adv'];
    544544            if($disable_cod_adv && $disable_cod_adv=='yes'){return $totals;}
    545            
     545
    546546            $current_gateway_id = $current_gateways_detail->id;
    547547            $current_gateway_title = $current_gateways_detail->title;
     
    554554            $extra_charges_msg = $current_gateways_detail->settings['extra_charges_msg'];
    555555            if(!$extra_charges_msg){$extra_charges_msg = 'COD Charges';}
    556            
     556
    557557            //get cart total
    558558            $total = $woocommerce->cart->subtotal;
    559        
     559
    560560            if($extra_charges){
    561561                if($extra_charges_type=="percentage"){
     
    568568                    $extra_add = $roundup_type -($total%$roundup_type);
    569569                    $total = $total+$extra_add;
    570                     $extra_charges = $extra_charges+$extra_add;                 
    571                 }
    572                
     570                    $extra_charges = $extra_charges+$extra_add;
     571                }
     572
    573573                //$this->current_extra_charge_min_amount = $extra_charge_min_amount;
    574574                //$this->current_gateway_title = $current_gateway_title;
    575                 //$this->current_gateway_extra_charges = $extra_charges;               
     575                //$this->current_gateway_extra_charges = $extra_charges;
    576576                //$this->current_gateway_extra_charges_type_value = $extra_charges_type;
    577577                $extra_fee_option_taxable = 0;
     
    580580                $extra_fee_option_label = $extra_charges_msg;
    581581                if($extra_charge_min_amount>=$total || empty($extra_charge_min_amount)){
    582                     $woocommerce->cart->add_fee($extra_fee_option_label, $extra_charges, $extra_fee_option_taxable );               
    583                 }
    584             }
    585         }
    586        
    587     }
    588    
     582                    $woocommerce->cart->add_fee($extra_fee_option_label, $extra_charges, $extra_fee_option_taxable );
     583                }
     584            }
     585        }
     586
     587    }
     588
    589589}
    590590
     591
     592if( is_admin() )
     593{
     594  add_action( 'current_screen', 'az_cod_selective_loading' );
     595} else new WooCommerceCODAdvanced();
     596
     597function az_cod_selective_loading() {
     598  if(function_exists('get_current_screen'))
     599  {
     600      $current_screen = get_current_screen();
     601      if( is_admin() && $current_screen->id != 'woocommerce_page_wc-settings')
     602        return ;
     603  }
     604
    591605new WooCommerceCODAdvanced();
     606
     607}
Note: See TracChangeset for help on using the changeset viewer.