Changeset 1676034
- Timestamp:
- 06/11/2017 04:50:23 PM (9 years ago)
- Location:
- woocommerce-cod-advanced/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
woocommerce_advanced_cod.php (modified) (47 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woocommerce-cod-advanced/trunk/readme.txt
r1375606 r1676034 3 3 Tags: woocommerce, cod, cash on delivery,cod advanced, minimum amount 4 4 Requires at least : 3.0.0 5 Tested up to: 4. 36 Stable tag: 1. 0.0.05 Tested up to: 4.8 6 Stable tag: 1.3 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 43 43 44 44 45 = 1.3.0 = 46 * Bug fixes. 47 48 45 49 = 1.0.0 = 46 50 * 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 SOLVED75 76 77 = 1.0.6 =78 * PHP syntax - Error SOLVED79 80 81 = 1.0.7 =82 * Added New COD icon for checkout page83 * 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 Solved114 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 4 4 Plugin URI: http://aheadzen.com/ 5 5 Description: 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 6 Author: Aheadzen Team 7 7 Version: 1.2.7 8 8 Author URI: http://aheadzen.com/ … … 24 24 add_action('wp_head',array($this,'adv_cod_wp_header'), 99 ); 25 25 add_filter('woocommerce_gateway_icon',array($this,'adv_cod_gateway_icon'),9,2); 26 26 27 27 add_action('woocommerce_cart_calculate_fees',array( &$this, 'woo_add_extra_fee')); 28 28 29 29 add_action('init',array($this,'az_woocod_init')); 30 30 31 31 global $woocommerce; 32 32 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 } 35 35 } 36 37 36 37 38 38 function az_woocod_init(){ 39 39 load_plugin_textdomain('askoracle', false, basename( dirname( __FILE__ ) ) . '/languages'); 40 40 } 41 41 42 42 /**************************** 43 43 COD header … … 55 55 <?php 56 56 } 57 57 58 58 /**************************** 59 59 COD admin options … … 64 64 $allowed_countries = $woocommerce->countries->get_allowed_countries(); 65 65 asort( $allowed_countries ); 66 66 67 67 $form_fields['cod_adv_title'] = array( 68 68 'title' => __('WooCommerce Advanced COD Plugin Settings','askoracle'), … … 70 70 'default' => 'no', 71 71 ); 72 72 73 73 $form_fields['disable_cod_adv'] = array( 74 74 'title' => __('Disable Advanced COD?','askoracle'), … … 78 78 'desc_tip' => '0', 79 79 ); 80 80 81 81 $form_fields['cod_icon'] = array( 82 82 'title' => __('Display icon on checkout page?','askoracle'), … … 86 86 'desc_tip' => '0', 87 87 ); 88 88 89 89 $form_fields['min_amount'] = array( 90 90 'title' => __('Minimum cart amount to display','askoracle'), … … 94 94 'desc_tip' => '0', 95 95 ); 96 96 97 97 $form_fields['max_amount'] = array( 98 98 'title' => __('Maximum cart amount to hide','askoracle'), … … 102 102 'desc_tip' => '0', 103 103 ); 104 104 105 105 $form_fields['extra_charge_min_amount'] = array( 106 106 'title' => __('Minimum cart amount for free COD','askoracle'), … … 110 110 'desc_tip' => '0', 111 111 ); 112 112 113 113 $form_fields['extra_charges'] = array( 114 114 'title' => __('Extra charges','askoracle'), … … 118 118 'desc_tip' => '0', 119 119 ); 120 120 121 121 $form_fields['extra_charges_msg'] = array( 122 122 'title' => __('Message for extra charges','askoracle'), … … 126 126 'desc_tip' => '', 127 127 ); 128 128 129 129 $form_fields['extra_charges_type'] = array( 130 130 'title' => __('Extra charges type','askoracle'), … … 135 135 'options' => array('amount'=>__('Total Add','askoracle'),'percentage'=>__('Total % Add','askoracle')) 136 136 ); 137 137 138 138 $form_fields['roundup_type'] = array( 139 139 'title' => __('Round up total amount by','askoracle'), … … 144 144 'options' => array('0'=>0,'5'=>5,'10'=>10,'50'=>50,'100'=>100) 145 145 ); 146 147 146 147 148 148 /**Category**/ 149 149 $cat_arr = array(); … … 160 160 'options' => $cat_arr 161 161 ); 162 162 163 163 /**Country**/ 164 164 $country_arr = array(); … … 185 185 'options' => $country_arr 186 186 ); 187 187 188 188 $form_fields['in_ex_country'] = array( 189 189 'title' => __('Country include/exclude?','askoracle'), … … 194 194 'include' => __('Display COD if user is from above country', 'askoracle' ), 195 195 'exclude' => __('Hide COD if user is from above country', 'askoracle' ) 196 ), 197 ); 198 199 200 /**States**/ 196 ), 197 ); 198 199 200 /**States**/ 201 201 $state_arr = array(); 202 202 if ( $woocommerce->countries->get_allowed_country_states() ) { … … 222 222 'options' => $state_arr 223 223 ); 224 224 225 225 $form_fields['in_ex_states'] = array( 226 226 'title' => __('States/Provinces include/exclude?','askoracle'), … … 231 231 'include' => __('Display COD if user is from above state', 'askoracle' ), 232 232 'exclude' => __('Hide COD if user is from above state', 'askoracle' ) 233 ), 234 ); 235 233 ), 234 ); 235 236 236 $form_fields['city'] = array( 237 237 'title' => __('Enter Cities','askoracle'), … … 241 241 'desc_tip' => '0', 242 242 ); 243 243 244 244 $form_fields['in_ex_city'] = array( 245 245 'title' => __('City include/exclude?','askoracle'), … … 250 250 'include' => __('Display COD if user is from above city', 'askoracle' ), 251 251 'exclude' => __('Hide COD if user is from above city', 'askoracle' ) 252 ), 253 ); 254 252 ), 253 ); 254 255 255 $form_fields['cod_pincodes'] = array( 256 256 'title' => __('Postal/Pin codes to hide COD','askoracle'), … … 260 260 'desc_tip' => '0', 261 261 ); 262 262 263 263 $form_fields['in_ex_pincode'] = array( 264 264 'title' => __('Postal/Pin code include/exclude?','askoracle'), … … 269 269 'include' => __('Display COD if user is from above postal code', 'askoracle' ), 270 270 'exclude' => __('Hide COD if user is from above postal code', 'askoracle' ) 271 ), 272 ); 273 271 ), 272 ); 273 274 274 $form_fields['hide_virtual_product'] = array( 275 275 'title' => __('Hide for virtual and downloadable products?','askoracle'), … … 279 279 'desc_tip' => '0', 280 280 ); 281 281 282 282 $form_fields['hide_virtual_product_msg'] = array( 283 283 'title' => __('COD hide message','askoracle'), … … 286 286 'default' => '', 287 287 'desc_tip' => '0', 288 ); 289 288 ); 289 290 290 return $form_fields; 291 291 } 292 292 293 293 294 294 /**************************** 295 295 COD filter show/hide COD … … 302 302 global $wpdb,$woocommerce,$hide_virtual_product_msg; 303 303 $settings = get_option('woocommerce_cod_settings'); 304 304 305 305 if($settings['disable_cod_adv'] && $settings['disable_cod_adv']=='yes'){return $gateways;} 306 306 if(isset($settings) && $settings) 307 307 { 308 308 $min_cod_amount = $settings['min_amount']; 309 $max_cod_amount = $settings['max_amount']; 309 $max_cod_amount = $settings['max_amount']; 310 310 $exclude_country = $settings['country']; 311 311 $in_ex_country = $settings['in_ex_country']; … … 347 347 } 348 348 } 349 349 350 350 global $woocommerce; 351 351 if($_POST['action'] == 'woocommerce_update_order_review' || $_GET['wc-ajax']=='update_order_review'){ … … 354 354 $customer_detail = WC()->session->get('customer'); 355 355 } 356 356 357 357 if($cod_enabled && $exclude_country){ 358 358 if($customer_detail['s_country']){ … … 364 364 unset($gateways['cod']); 365 365 $cod_enabled=0; 366 }else 366 }else 367 367 if($shipping_country && $in_ex_country=='exclude' && in_array($shipping_country,$exclude_country)){ 368 368 unset($gateways['cod']); 369 369 $cod_enabled=0; 370 } 371 } 372 370 } 371 } 372 373 373 if($cod_enabled && $exclude_states){ 374 374 if($customer_detail['s_country'] && $customer_detail['s_state']){ … … 377 377 $shipping_state = trim($customer_detail['shipping_country'].':'.$customer_detail['shipping_state']); 378 378 } 379 379 380 380 if($shipping_state && $in_ex_states=='include' && !in_array($shipping_state,$exclude_states)){ 381 381 unset($gateways['cod']); … … 393 393 }else{ 394 394 $shipping_city = strtolower(trim($customer_detail['shipping_city'])); 395 } 396 395 } 396 397 397 if($exclude_city_arr && $in_ex_city=='include' && !in_array($shipping_city,$exclude_city_arr)){ 398 398 unset($gateways['cod']); … … 403 403 } 404 404 } 405 405 406 406 if($cod_enabled && $cod_pincodes){ 407 $cod_pincodes_arr = explode(',',$cod_pincodes); 407 $cod_pincodes_arr = explode(',',$cod_pincodes); 408 408 if($customer_detail['s_city']){ 409 409 $shipping_postcode = trim($customer_detail['s_postcode']); … … 419 419 } 420 420 } 421 421 422 422 $total = $woocommerce->cart->total; 423 423 if(!$total){$total = $woocommerce->cart->cart_contents_total;} … … 426 426 $cod_enabled=0; 427 427 } 428 428 429 429 if($cod_enabled && $max_cod_amount && $woocommerce->cart && $total>=$max_cod_amount){ 430 430 unset($gateways['cod']); 431 431 $cod_enabled=0; 432 432 } 433 433 434 434 if($hide_virtual_product=='yes'){ 435 435 $the_cart_contents = $woocommerce->cart->cart_contents; … … 445 445 } 446 446 if($cod_enabled==0 && $hide_virtual_product_msg!=''){ 447 447 448 448 add_filter('woocommerce_update_order_review_fragments', 'woocommerce_checkout_after_order_review_filter'); 449 449 if(!function_exists('woocommerce_checkout_after_order_review_filter')){ … … 455 455 return $vals; 456 456 } 457 } 457 } 458 458 } 459 459 return $gateways; 460 460 } 461 461 462 462 /**************************** 463 463 COD ICON … … 465 465 function adv_cod_gateway_icon($icon_html,$id) 466 466 { 467 $settings = get_option('woocommerce_cod_settings'); 467 $settings = get_option('woocommerce_cod_settings'); 468 468 $cod_icon = $settings['cod_icon']; 469 469 if($id=='cod' && $cod_icon=='yes'){ … … 473 473 return $icon_html; 474 474 } 475 475 476 476 /**************************** 477 477 COD calculate Totals 478 478 ****************************/ 479 public function adv_cod_calculate_totals( $totals ) { 479 public function adv_cod_calculate_totals( $totals ) { 480 480 $available_gateways = WC()->payment_gateways->get_available_payment_gateways(); 481 481 $current_gateway = WC()->session->chosen_payment_method; … … 484 484 $disable_cod_adv = $current_gateways_detail->settings['disable_cod_adv']; 485 485 if($disable_cod_adv && $disable_cod_adv=='yes'){return $totals;} 486 486 487 487 $current_gateway_id = $current_gateways_detail->id; 488 488 $current_gateway_title = $current_gateways_detail->title; … … 493 493 $extra_charges_type = $current_gateways_detail->settings['extra_charges_type']; 494 494 $roundup_type = $current_gateways_detail->settings['roundup_type']; 495 495 496 496 if($extra_charges && $extra_charge_min_amount>=$totals->cart_contents_total){ 497 497 if($extra_charges_type=="percentage"){ … … 504 504 $extra_add = $roundup_type -($totals->cart_contents_total%$roundup_type); 505 505 $totals->cart_contents_total = $totals->cart_contents_total+$extra_add; 506 $extra_charges = $extra_charges+$extra_add; 506 $extra_charges = $extra_charges+$extra_add; 507 507 } 508 508 $this->current_extra_charge_min_amount = $extra_charge_min_amount; 509 509 $this->current_gateway_title = $current_gateway_title; 510 $this->current_gateway_extra_charges = $extra_charges; 510 $this->current_gateway_extra_charges = $extra_charges; 511 511 $this->current_gateway_extra_charges_type_value = $extra_charges_type; 512 512 add_action( 'woocommerce_review_order_before_order_total', array( $this, 'adv_cod_add_payment_gateway_extra_charges_row')); … … 517 517 return $totals; 518 518 } 519 519 520 520 /**************************** 521 521 COD extra charge … … 533 533 <?php 534 534 } 535 535 536 536 public function woo_add_extra_fee() { 537 537 global $woocommerce; … … 540 540 if($current_gateway=='cod'){ 541 541 $current_gateways_detail = $available_gateways[$current_gateway]; 542 542 543 543 $disable_cod_adv = $current_gateways_detail->settings['disable_cod_adv']; 544 544 if($disable_cod_adv && $disable_cod_adv=='yes'){return $totals;} 545 545 546 546 $current_gateway_id = $current_gateways_detail->id; 547 547 $current_gateway_title = $current_gateways_detail->title; … … 554 554 $extra_charges_msg = $current_gateways_detail->settings['extra_charges_msg']; 555 555 if(!$extra_charges_msg){$extra_charges_msg = 'COD Charges';} 556 556 557 557 //get cart total 558 558 $total = $woocommerce->cart->subtotal; 559 559 560 560 if($extra_charges){ 561 561 if($extra_charges_type=="percentage"){ … … 568 568 $extra_add = $roundup_type -($total%$roundup_type); 569 569 $total = $total+$extra_add; 570 $extra_charges = $extra_charges+$extra_add; 571 } 572 570 $extra_charges = $extra_charges+$extra_add; 571 } 572 573 573 //$this->current_extra_charge_min_amount = $extra_charge_min_amount; 574 574 //$this->current_gateway_title = $current_gateway_title; 575 //$this->current_gateway_extra_charges = $extra_charges; 575 //$this->current_gateway_extra_charges = $extra_charges; 576 576 //$this->current_gateway_extra_charges_type_value = $extra_charges_type; 577 577 $extra_fee_option_taxable = 0; … … 580 580 $extra_fee_option_label = $extra_charges_msg; 581 581 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 589 589 } 590 590 591 592 if( is_admin() ) 593 { 594 add_action( 'current_screen', 'az_cod_selective_loading' ); 595 } else new WooCommerceCODAdvanced(); 596 597 function 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 591 605 new WooCommerceCODAdvanced(); 606 607 }
Note: See TracChangeset
for help on using the changeset viewer.