Changeset 3327241
- Timestamp:
- 07/13/2025 11:04:58 PM (7 months ago)
- Location:
- wc-smart-cod
- Files:
-
- 10 edited
- 6 copied
-
tags/1.8.0 (copied) (copied from wc-smart-cod/trunk)
-
tags/1.8.0/README.txt (copied) (copied from wc-smart-cod/trunk/README.txt) (1 diff)
-
tags/1.8.0/admin/class-wc-smart-cod-admin.php (copied) (copied from wc-smart-cod/trunk/admin/class-wc-smart-cod-admin.php) (36 diffs)
-
tags/1.8.0/admin/css/wc-smart-cod-admin.css (modified) (1 diff)
-
tags/1.8.0/admin/js/wc-smart-cod-admin.min.js (modified) (1 diff)
-
tags/1.8.0/includes/class-wc-smart-cod-notification-settings.php (modified) (2 diffs)
-
tags/1.8.0/includes/class-wc-smart-cod.php (copied) (copied from wc-smart-cod/trunk/includes/class-wc-smart-cod.php) (4 diffs)
-
tags/1.8.0/public/class-wc-smart-cod-public.php (copied) (copied from wc-smart-cod/trunk/public/class-wc-smart-cod-public.php)
-
tags/1.8.0/wc-smart-cod.php (copied) (copied from wc-smart-cod/trunk/wc-smart-cod.php) (2 diffs)
-
trunk/README.txt (modified) (1 diff)
-
trunk/admin/class-wc-smart-cod-admin.php (modified) (36 diffs)
-
trunk/admin/css/wc-smart-cod-admin.css (modified) (1 diff)
-
trunk/admin/js/wc-smart-cod-admin.min.js (modified) (1 diff)
-
trunk/includes/class-wc-smart-cod-notification-settings.php (modified) (2 diffs)
-
trunk/includes/class-wc-smart-cod.php (modified) (4 diffs)
-
trunk/wc-smart-cod.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wc-smart-cod/tags/1.8.0/README.txt
r3277209 r3327241 3 3 Tags: WooCommerce, Cash on Delivery, COD, COD Extra Fee, Smart COD, WooCommerce COD, Multiple Fees 4 4 Requires at least: 3.0.1 5 Tested up to: 6.8 6 Stable tag: 1. 7.35 Tested up to: 6.8.1 6 Stable tag: 1.8.0 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
wc-smart-cod/tags/1.8.0/admin/class-wc-smart-cod-admin.php
r3277209 r3327241 51 51 public $new_wc = false; 52 52 53 private $restriction_settings = array(); 54 55 private $fee_settings = array(); 56 57 private $prepared_fields = array(); 58 59 private $settings_manager = array(); 60 53 61 public function __construct() { 54 62 … … 56 64 $this->plugin_name = 'wc-smart-cod'; 57 65 $this->version = SMART_COD_VER; 66 67 $this->settings_manager = (object)Wc_Smart_Cod::get_settings_manager(); 58 68 59 69 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); 60 70 add_action( 'woocommerce_settings_api_form_fields_cod', array( $this, 'extend_cod' ) ); 61 71 add_action( 'woocommerce_settings_api_sanitized_fields_cod', array( $this, 'clean_up_settings' ) ); 72 add_filter( 'experimental_woocommerce_admin_payment_reactify_render_sections', array( $this, 'woocommerce_smart_cod') ); 62 73 add_action( 'woocommerce_delete_shipping_zone', array( $this, 'clean_up_gateway' ) ); 63 74 } … … 144 155 echo '</h2>'; 145 156 echo wp_kses_post( wpautop( $this->get_method_description() ) ); 157 146 158 $template_data = array( 147 159 'promo_texts' => WC_Smart_Cod::$promo_texts, … … 221 233 } 222 234 235 public function woocommerce_smart_cod($sections) { 236 $cod = 'cod'; 237 return array_filter($sections, function($v) use ($cod) { 238 return $v !== $cod; 239 }); 240 } 241 242 public function get_field_value($key, $field, $post_data = array()) 243 { 244 if ($this->has_prefix_in_array($key, $this->settings_manager->e)) { 245 if (!in_array($key, haystack: $this->settings_manager->d)) { 246 if (isset($this->settings[$key]) && $this->settings[$key] !== '') { 247 return $this->settings[$key]; 248 } 249 return ''; 250 } 251 } 252 return parent::get_field_value($key, $field, $post_data); 253 } 254 223 255 private function update_wc_smart_cod( $settings, $restriction_settings ) { 224 256 … … 258 290 } 259 291 292 /** 293 * Check if a string starts with any of the prefixes in an array. 294 * 295 * @param string $haystack The string to check. 296 * @param array $prefixes Array of possible prefixes. 297 * @return bool True if any prefix matches the start of the string. 298 */ 299 protected function has_prefix_in_array($haystack, $prefixes) { 300 foreach ($prefixes as $prefix) { 301 if (strncmp($haystack, $prefix, strlen($prefix)) === 0) { 302 return true; 303 } 304 } 305 return false; 306 } 307 260 308 protected function analyze_fields( $form_fields, $settings, $restriction_settings, $old_wc_smart_cod ) { 261 309 262 $fields = array();263 310 $fee_settings = array_key_exists( 'fee_settings', $settings ) ? $settings[ 'fee_settings' ] : false; 264 311 $fee_settings = $fee_settings ? json_decode( $fee_settings, true ) : array(); … … 274 321 $class_arr = explode( ' ', $field[ 'class' ] ); 275 322 323 /** 324 * - Checks if the current field has the 'wc-smart-cod-restriction' class: 325 * - Determines whether the restriction mode should be 'enable' or 'disable' based on $restriction_settings. 326 * - Updates the field title to reflect the enabled state if applicable. 327 * - Initializes restriction settings for new fields after plugin update. 328 * - Sets a custom data attribute 'data-mode' to indicate the current mode. 329 */ 276 330 if( in_array( 'wc-smart-cod-restriction', $class_arr ) ) { 277 331 // determine include or exclude … … 299 353 } 300 354 355 /* - Checks if the current field has the 'wc-smart-cod-percentage' class: 356 * - Ensures the fee type is set (defaults to 'fixed' if not present). 357 * - Marks that fee settings need to be updated if a new key is added. 358 */ 301 359 if( in_array( 'wc-smart-cod-percentage', $class_arr ) ) { 302 360 … … 311 369 } 312 370 371 if ($this->settings_manager && count($this->settings_manager->e) > 0) { 372 if ($this->has_prefix_in_array($key, $this->settings_manager->e)) { 373 374 if(!in_array($key, $this->settings_manager->d)) { 375 $needle = $this->get_dsb_key(true); 376 $form_fields[ $key ][ $this->get_dsb_key() ] = true; 377 $form_fields[ $key ][ $needle ] = $field[ $needle ] . ' wc-smart-cod-pro-field'; 378 } 379 380 } 381 } 313 382 } 314 383 … … 336 405 } 337 406 407 private function get_dsb_key( $needle = false ) { 408 return $needle ? "class" : "disabled"; 409 } 410 338 411 public function extend_cod( $form_fields ) { 339 412 $this->prepared_fields = $this->get_prepared_fields(); … … 389 462 $this->new_wc = class_exists( 'WC_Shipping_Zones' ) ? true : false; 390 463 $existing_settings = $this->settings; 391 $existing_zone_restrictions = array();392 464 $countries = new WC_Countries; 393 465 $states = $countries->get_allowed_country_states(); … … 468 540 'data-placeholder' => __( 'Select shipping zones', 'wc-smart-cod' ), 469 541 'data-name' => 'shipping_zone_restrictions' 470 ) 542 ), 543 'disabled' => false 471 544 ); 472 545 … … 483 556 'data-placeholder' => __( 'Select Countries', 'wc-smart-cod' ), 484 557 'data-name' => 'country_restrictions' 485 ) 558 ), 559 'disabled' => false 486 560 ); 487 561 … … 496 570 'data-placeholder' => __( 'Select States', 'wc-smart-cod' ), 497 571 'data-name' => 'state_restrictions' 498 ) 572 ), 573 'disabled' => false 499 574 ); 500 575 … … 506 581 'custom_attributes' => array( 507 582 'data-name' => 'restrict_postals' 508 ) 583 ), 584 'disabled' => false 509 585 ); 510 586 … … 516 592 'custom_attributes' => array( 517 593 'data-name' => 'city_restrictions' 518 ) 594 ), 595 'disabled' => false 519 596 ); 520 597 … … 527 604 'custom_attributes' => array( 528 605 'data-name' => 'cart_amount_restriction' 529 ) 606 ), 607 'disabled' => false 530 608 ); 531 609 … … 540 618 'data-placeholder' => __( 'Select Roles', 'wc-smart-cod' ), 541 619 'data-name' => 'user_role_restriction' 542 ) 620 ), 621 'disabled' => false 543 622 ); 544 623 … … 553 632 ), 554 633 'default' => 'one_product', 555 'description' => __( 'Select "at least one", if you want the COD to be restricted when at least one product of the cart belongs to a restricted category. Select "all", if you want the COD to be restricted if all the cart product\'s belongs to restricted categories. Then add the restricted categories in the select field below.', 'wc-smart-cod' ) 634 'description' => __( 'Select "at least one", if you want the COD to be restricted when at least one product of the cart belongs to a restricted category. Select "all", if you want the COD to be restricted if all the cart product\'s belongs to restricted categories. Then add the restricted categories in the select field below.', 'wc-smart-cod' ), 635 'disabled' => false 556 636 ); 557 637 … … 568 648 'data-name' => 'category_restriction', 569 649 'data-action' => 'wcsmartcod_json_search_categories' 570 ) 650 ), 651 'disabled' => false 571 652 ); 572 653 … … 581 662 ), 582 663 'default' => 'one_product', 583 'description' => __( 'Select "at least one", if you want the COD to be restricted when at least one product of the cart is restricted. Select "all", if you want the COD to be restricted if all of the cart\'s product\'s are restricted. Then add the restricted products in the select field below.', 'wc-smart-cod' ) 664 'description' => __( 'Select "at least one", if you want the COD to be restricted when at least one product of the cart is restricted. Select "all", if you want the COD to be restricted if all of the cart\'s product\'s are restricted. Then add the restricted products in the select field below.', 'wc-smart-cod' ), 665 'disabled' => false 584 666 ); 585 667 … … 596 678 'data-minimum_input_length' => '1', 597 679 'data-name' => 'product_restriction' 598 ) 680 ), 681 'disabled' => false 599 682 ); 600 683 … … 609 692 ), 610 693 'default' => 'one_product', 611 'description' => __( 'Select "at least one", if you want the COD to be restricted when at least one product of the cart belongs to a restricted shipping class. Select "all", if you want the COD to be restricted if all of the cart\'s product\'s belongs to restricted shipping classes. Then add the restricted shipping classes in the select field below.', 'wc-smart-cod' ) 694 'description' => __( 'Select "at least one", if you want the COD to be restricted when at least one product of the cart belongs to a restricted shipping class. Select "all", if you want the COD to be restricted if all of the cart\'s product\'s belongs to restricted shipping classes. Then add the restricted shipping classes in the select field below.', 'wc-smart-cod' ), 695 'disabled' => false 612 696 ); 613 697 … … 622 706 'data-placeholder' => __( 'Select Shipping Classes', 'wc-smart-cod' ), 623 707 'data-name' => 'shipping_class_restriction' 624 ) 708 ), 709 'disabled' => false 625 710 ); 626 711 … … 642 727 'type' => 'cod_messages', 643 728 'class' => 'wc-smart-cod-group', 644 'description' => __( 'An informational text to display before the payment methods, when the COD method is not available for a customer. Leave it empty if you don\'t want to use this feature. You can define different messages per reason.', 'wc-smart-cod' ) 729 'description' => __( 'An informational text to display before the payment methods, when the COD method is not available for a customer. Leave it empty if you don\'t want to use this feature. You can define different messages per reason.', 'wc-smart-cod' ), 730 'disabled' => false 645 731 ); 646 732 … … 651 737 'description' => __( 'The extra amount you charging for cash on delivery (leave blank or zero if you don\'t charge extra)', 'wc-smart-cod' ), 652 738 'desc_tip' => true, 653 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ) 739 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ), 740 'disabled' => false 654 741 ); 655 742 … … 665 752 'default' => 'round_up', 666 753 'description' => __( 'Examples: Round up setting will transform 5.345€ to 6€<br />Round down will transform it to 5€.', 'wc-smart-cod' ), 667 'desc_tip' => false 754 'desc_tip' => false, 755 'disabled' => false 668 756 ); 669 757 … … 679 767 'default' => 'disable', 680 768 'description' => __( 'Is extra fee taxable? Use this option if you have taxes enabled in your shop and you want to include tax to COD method.', 'wc-smart-cod' ), 681 'desc_tip' => false 769 'desc_tip' => false, 770 'disabled' => false 682 771 ); 683 772 … … 691 780 'custom_attributes' => array( 692 781 'data-name' => 'nocharge_amount' 693 ) 782 ), 783 'disabled' => false 694 784 ); 695 785 … … 712 802 'default' => array( 'tax', 'shipping' ), 713 803 'description' => __( 'This setting affect those settings: "Disable extra fee if cart amount is greater than this limit." and "Disable if cart amount is greater than". <strong>It defines what is finally calculated as the cart amount.</strong>', 'wc-smart-cod' ), 714 'desc_tip' => false 804 'desc_tip' => false, 805 'disabled' => false 715 806 ); 716 807 … … 724 815 'desc_tip' => true, 725 816 'class' => 'wc-smart-cod-group wc-smart-cod-percentage', 726 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ) 817 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ), 818 'disabled' => false 727 819 ); 728 820 } … … 748 840 'desc_tip' => true, 749 841 'class' => 'wc-smart-cod-group wc-smart-cod-percentage', 750 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ) 842 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ), 843 'disabled' => false 751 844 ); 752 845 … … 786 879 'desc_tip' => true, 787 880 'class' => 'wc-smart-cod-group wc-smart-cod-fee wc-smart-cod-percentage', 788 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ) 881 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ), 882 'disabled' => false 789 883 ); 790 884 … … 825 919 'desc_tip' => true, 826 920 'class' => 'wc-smart-cod-group wc-smart-cod-fee wc-smart-cod-percentage', 827 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ) 921 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ), 922 'disabled' => false 828 923 ); 829 924 } … … 838 933 $form_fields[ 'fee_settings' ] = array( 839 934 'type' => 'hidden' 935 ); 936 937 $form_fields[ 'risk_free_advance_payment' ] = array( 938 'title' => __( 'Partial payment amount for COD orders', 'wc-smart-cod' ), 939 'type' => 'price', 940 'class' => 'wc-smart-cod-group wc-smart-cod-percentage', 941 'description' => __( 'Require customers to pay a portion of the order in advance, before processing a Cash on Delivery order.', 'wc-smart-cod' ), 942 'desc_tip' => true, 943 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ), 944 'disabled' => true 840 945 ); 841 946 … … 1117 1222 unset( $settings [ $key ] ); 1118 1223 } 1119 1120 1224 } 1121 1225 … … 1194 1298 'enhanced_select' => $enhanced_select_variables, 1195 1299 'restriction_settings' => ( object ) $this->get_json_settings( 'restriction_settings' ), 1196 'fee_settings' => ( object ) $this->get_json_settings( 'fee_settings' ) 1300 'fee_settings' => ( object ) $this->get_json_settings( 'fee_settings' ), 1301 'pro_site_url' => $this->settings_manager->l 1197 1302 ); 1198 1303 -
wc-smart-cod/tags/1.8.0/admin/css/wc-smart-cod-admin.css
r2918131 r3327241 92 92 } 93 93 94 .pro-badge { 95 margin: 5px 0; 96 } 97 98 .pro-badge a { 99 display: inline-block; 100 padding: 4px 10px; 101 font-size: 10px; 102 font-weight: 600; 103 color: #fff; 104 background: #403447; 105 border-radius: 999px; 106 box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); 107 letter-spacing: 0.5px; 108 user-select: none; 109 cursor: pointer; 110 text-transform: none; 111 text-decoration: none; 112 transition: all 0.2s ease-in; 113 } 114 115 .pro-badge a:hover { 116 background-color: #481c41; 117 } 118 119 .woocommerce_page_wc-settings-checkout-cod form h2 { 120 padding-top: 15px; 121 } 122 94 123 @media screen and (min-width: 1200px) { 95 124 -
wc-smart-cod/tags/1.8.0/admin/js/wc-smart-cod-admin.min.js
r2376032 r3327241 1 jQuery(document).ready( function(e){var t=e("#mainform"),a=e(".woocommerce-save-button"),n=e(".wc-smart-cod-group"),c=e(".wc-smartcod-categories, .wc-smartcod-products"),r=e(".wc-smartcod-products.wc-smart-cod-group"),i=e(".wc-smart-cod-restriction"),s=e(".wc-smart-cod-percentage"),o=e("body"),d=e("#woocommerce_cod_restriction_settings"),l=e("#woocommerce_cod_fee_settings"),_=e(".wsc-message-switcher"),m=e(".wsc-message"),u={},h={};smart_cod_variables.hasOwnProperty("restriction_settings")&&(u=smart_cod_variables.restriction_settings),smart_cod_variables.hasOwnProperty("fee_settings")&&(h=smart_cod_variables.fee_settings);var p={init:function(){d.parents("tr").addClass("hidden"),l.parents("tr").addClass("hidden"),i.each(function(t,a){p.enableConditional(e(this))}),s.each(function(t,a){p.enablePercentage(e(this))}),o.on("change",".wc-smart-cod-percantage-switcher",p.switchFee),o.on("click",".wc-smart-cod-mode",p.switchMode),a.click(function(e){p.validateFields(n)||e.preventDefault()}),c.each(function(t,a){p.initSelect2(e(this))}),p.fixSelect2Bug(r),_.on("change",p.changeMessageVisibility)},changeMessageVisibility:function(t){e(this);var a=e(this).val();m.addClass("hidden"),e('.wsc-message[data-restriction="'+a+'"]').removeClass("hidden")},isObjectEmpty:function(e){var t;for(t in e)return!1;return!0},switchMode:function(t){t.preventDefault();var a=e(this),n=a.data("mode"),c="enable"===n?"disable":"enable",r=a.parents("tr").find(".wc-smart-cod-restriction").data("name");"enable"!==n&&"disable"!==n||(u[r]="enable"===c?1:0,d.val(JSON.stringify(u)),a.html(c),a.data("mode",c))},switchFee:function(t){var a=e(this),n=a.prev(),c=a.val(),r=n.attr("name");h[r.slice(16)]=c,l.val(JSON.stringify(h))},enablePercentage:function(t){var a=t.parents("fieldset"),n=e('<select class="wc-smart-cod-percantage-switcher"><option value="fixed">Fixed</option><option value="percentage">%</option></select>'),c="0",r=t.attr("name").slice(16);h.hasOwnProperty(r)?c=h[r]:h[r]=c="fixed",n.val(c),a.append(n)},enableConditional:function(e){var t=e.parents("tr").find("th").find("label");if(t.length>0){var a=t.contents().get(0).nodeValue,n=a.trim().split(" ");if(n[0]){var c=n[0].toLowerCase();switch(c){case"enable":case"disable":var r=e.attr("name"),i=e.data("name");t.contents().get(0).nodeValue=t.text().replace(a,""),n.shift(),t.prepend('<a class="wc-smart-cod-mode" href="#" data-mode="'+c+'" data-input-name="'+r+'">'+c+"</a> "+n.join(" ")),u.hasOwnProperty(i)||(u[i]="enable"===c?1:0)}}}},fixSelect2Bug:function(e){var t=e.data("select2");t&&t.on("results:message",function(e){this.dropdown._resizeDropdown(),this.dropdown._positionDropdown()})},initSelect2:function(t){var a,n=t.data("action")||"woocommerce_json_search_categories";"wcsmartcod_json_search_categories"===n?a=smart_cod_variables.enhanced_select.search_categories_nonce:"woocommerce_json_search_products_and_variations"===n&&(a=smart_cod_variables.enhanced_select.search_products_nonce);var c={allowClear:!!t.data("allow_clear"),placeholder:t.data("placeholder"),minimumInputLength:t.data("minimum_input_length")?t.data("minimum_input_length"):"3",escapeMarkup:function(e){return e},ajax:{url:smart_cod_variables.enhanced_select.ajax_url,dataType:"json",delay:250,data:function(e){return{term:e.term,action:n,security:a,exclude:t.data("exclude"),include:t.data("include"),limit:t.data("limit")}},processResults:function(t){var a=[];return t&&e.each(t,function(e,t){a.push({id:e,text:t})}),{results:a}},cache:!0}};c=e.extend(c,p.getEnhancedSelectFormatString()),t.select2(c).addClass("enhanced")},validateFields:function(a){t.find(".field-error").remove();return a.each(function(t,a){if("woocommerce_cod_include_restrict_postals"!==a.id&&"woocommerce_cod_restrict_postals"!==a.id)return!0;var n=e(this),c=n.val()?n.val().replace(/\s/g,""):n.val();n.val(c)}),!0},getEnhancedSelectFormatString:function(){return{language:{errorLoading:function(){return smart_cod_variables.enhanced_select.i18n_searching},inputTooLong:function(e){var t=e.input.length-e.maximum;return 1===t?smart_cod_variables.enhanced_select.i18n_input_too_long_1:smart_cod_variables.enhanced_select.i18n_input_too_long_n.replace("%qty%",t)},inputTooShort:function(e){var t=e.minimum-e.input.length;return 1===t?smart_cod_variables.enhanced_select.i18n_input_too_short_1:smart_cod_variables.enhanced_select.i18n_input_too_short_n.replace("%qty%",t)},loadingMore:function(){return smart_cod_variables.enhanced_select.i18n_load_more},maximumSelected:function(e){return 1===e.maximum?smart_cod_variables.enhanced_select.i18n_selection_too_long_1:smart_cod_variables.enhanced_select.i18n_selection_too_long_n.replace("%qty%",e.maximum)},noResults:function(){return smart_cod_variables.enhanced_select.i18n_no_matches},searching:function(){return smart_cod_variables.enhanced_select.i18n_searching}}}}};p.init()});1 jQuery(document).ready((function(e){var t=e("#mainform"),a=e(".woocommerce-save-button"),n=e(".wc-smart-cod-group"),r=e(".wc-smartcod-categories, .wc-smartcod-products"),i=e(".wc-smartcod-products.wc-smart-cod-group"),c=e(".wc-smart-cod-restriction"),s=e(".wc-smart-cod-percentage"),o=e("body"),d=e("#woocommerce_cod_restriction_settings"),l=e("#woocommerce_cod_fee_settings"),_=e(".wsc-message-switcher"),m=e(".wsc-message"),u=e(".wc-smart-cod-pro-field"),h={},p={},g="";smart_cod_variables.hasOwnProperty("restriction_settings")&&(h=smart_cod_variables.restriction_settings),smart_cod_variables.hasOwnProperty("fee_settings")&&(p=smart_cod_variables.fee_settings),smart_cod_variables.hasOwnProperty("pro_site_url")&&(g=smart_cod_variables.pro_site_url);var f={init:function(){d.parents("tr").addClass("hidden"),l.parents("tr").addClass("hidden"),c.each((function(t,a){f.enableConditional(e(this))})),s.each((function(t,a){f.enablePercentage(e(this))})),u.each((function(t,a){f.enableProField(e(this))})),o.on("change",".wc-smart-cod-percantage-switcher",f.switchFee),o.on("click",".wc-smart-cod-mode",f.switchMode),a.click((function(e){f.validateFields(n)||e.preventDefault()})),r.each((function(t,a){f.initSelect2(e(this))})),f.fixSelect2Bug(i),_.on("change",f.changeMessageVisibility)},changeMessageVisibility:function(t){e(this);var a=e(this).val();m.addClass("hidden"),e('.wsc-message[data-restriction="'+a+'"]').removeClass("hidden")},isObjectEmpty:function(e){var t;for(t in e)return!1;return!0},switchMode:function(t){t.preventDefault();var a=e(this),n=a.data("mode"),r="enable"===n?"disable":"enable",i=a.parents("tr").find(".wc-smart-cod-restriction").data("name");"enable"!==n&&"disable"!==n||(h[i]="enable"===r?1:0,d.val(JSON.stringify(h)),a.html(r),a.data("mode",r))},switchFee:function(t){var a=e(this),n=a.prev(),r=a.val(),i=n.attr("name");p[i.slice(16)]=r,l.val(JSON.stringify(p))},enablePercentage:function(t){var a=t.parents("fieldset"),n=e('<select class="wc-smart-cod-percantage-switcher"><option value="fixed">Fixed</option><option value="percentage">%</option></select>'),r="0",i=t.attr("name").slice(16);a.find("input").is(":disabled")&&n.prop("disabled",!0),p.hasOwnProperty(i)?r=p[i]:p[i]=r="fixed",n.val(r),a.append(n)},enableConditional:function(e){var t=e.parents("tr").find("th").find("label");if(t.length>0){var a=t.contents().get(0).nodeValue,n=a.trim().split(" ");if(n[0]){var r=n[0].toLowerCase();switch(r){case"enable":case"disable":var i=e.attr("name"),c=e.data("name");t.contents().get(0).nodeValue=t.text().replace(a,""),n.shift(),t.prepend('<a class="wc-smart-cod-mode" href="#" data-mode="'+r+'" data-input-name="'+i+'">'+r+"</a> "+n.join(" ")),h.hasOwnProperty(c)||(h[c]="enable"===r?1:0)}}}},enableProField:function(e){var t=e.parents("tr").find("th");t.length>0&&t.append('<p class="pro-badge"><a href="'+g+'" target="_blank">🚀 Available in PRO</a></p>')},fixSelect2Bug:function(e){var t=e.data("select2");t&&t.on("results:message",(function(e){this.dropdown._resizeDropdown(),this.dropdown._positionDropdown()}))},initSelect2:function(t){var a,n=t.data("action")||"woocommerce_json_search_categories";"wcsmartcod_json_search_categories"===n?a=smart_cod_variables.enhanced_select.search_categories_nonce:"woocommerce_json_search_products_and_variations"===n&&(a=smart_cod_variables.enhanced_select.search_products_nonce);var r={allowClear:!!t.data("allow_clear"),placeholder:t.data("placeholder"),minimumInputLength:t.data("minimum_input_length")?t.data("minimum_input_length"):"3",escapeMarkup:function(e){return e},ajax:{url:smart_cod_variables.enhanced_select.ajax_url,dataType:"json",delay:250,data:function(e){return{term:e.term,action:n,security:a,exclude:t.data("exclude"),include:t.data("include"),limit:t.data("limit")}},processResults:function(t){var a=[];return t&&e.each(t,(function(e,t){a.push({id:e,text:t})})),{results:a}},cache:!0}};r=e.extend(r,f.getEnhancedSelectFormatString()),t.select2(r).addClass("enhanced")},validateFields:function(a){t.find(".field-error").remove();return a.each((function(t,a){if("woocommerce_cod_include_restrict_postals"!==a.id&&"woocommerce_cod_restrict_postals"!==a.id)return!0;var n=e(this),r=n.val()?n.val().replace(/\s/g,""):n.val();n.val(r)})),!0},getEnhancedSelectFormatString:function(){return{language:{errorLoading:function(){return smart_cod_variables.enhanced_select.i18n_searching},inputTooLong:function(e){var t=e.input.length-e.maximum;return 1===t?smart_cod_variables.enhanced_select.i18n_input_too_long_1:smart_cod_variables.enhanced_select.i18n_input_too_long_n.replace("%qty%",t)},inputTooShort:function(e){var t=e.minimum-e.input.length;return 1===t?smart_cod_variables.enhanced_select.i18n_input_too_short_1:smart_cod_variables.enhanced_select.i18n_input_too_short_n.replace("%qty%",t)},loadingMore:function(){return smart_cod_variables.enhanced_select.i18n_load_more},maximumSelected:function(e){return 1===e.maximum?smart_cod_variables.enhanced_select.i18n_selection_too_long_1:smart_cod_variables.enhanced_select.i18n_selection_too_long_n.replace("%qty%",e.maximum)},noResults:function(){return smart_cod_variables.enhanced_select.i18n_no_matches},searching:function(){return smart_cod_variables.enhanced_select.i18n_searching}}}}};f.init()})); -
wc-smart-cod/tags/1.8.0/includes/class-wc-smart-cod-notification-settings.php
r2985727 r3327241 17 17 $res = wp_remote_get( 18 18 $this->settings_url, 19 array( 'timeout' => 1)19 array( 'timeout' => 5, 'headers' => $headers ) 20 20 ); 21 21 … … 24 24 } 25 25 26 $ok = ( $res 27 && isset( $res['response'] ) 28 && isset( $res['response']['code'] ) 29 && $res['response']['code'] === 200 30 ); 26 $ok = $res 27 && isset($res['response']) 28 && isset($res['response']['code']) 29 && $res['response']['code'] === 200; 31 30 32 31 if($ok) { -
wc-smart-cod/tags/1.8.0/includes/class-wc-smart-cod.php
r3277209 r3327241 80 80 $this->plugin_name = 'wc-smart-cod'; 81 81 82 define( 'SMART_COD_VER', '1. 7.3' );82 define( 'SMART_COD_VER', '1.8.0' ); 83 83 84 84 self::$version = SMART_COD_VER; 85 85 86 86 $this->load_notification_manager(); 87 88 $this->load_settings_manager(); 87 89 88 90 self::setup_promos(); … … 221 223 } 222 224 225 public static function get_settings_manager() { 226 227 $settings = get_transient( 'wc-smart-cod-settings' ); 228 229 if( $settings ) { 230 return $settings; 231 } 232 233 $settings_manager = new Wc_Smart_Cod_Settings_Manager( self::$pro_url ); 234 $settings = $settings_manager->get_settings_manager(); 235 236 set_transient( 'wc-smart-cod-settings', $settings, 86400 ); 237 238 return $settings; 239 } 240 223 241 public function activate_notice() { 224 242 … … 268 286 } 269 287 288 public function load_settings_manager() { 289 /** 290 * Class responsible for settings manager 291 */ 292 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc-smart-cod-settings-manager.php'; 293 } 294 270 295 public function load_dependencies() { 271 296 … … 339 364 340 365 /** 341 * Register all of the hooks related to the admin area functionality342 * of the plugin.343 *344 * @since 1.0.0345 * @access private346 */347 private function define_admin_hooks() {348 349 $plugin_admin = new Wc_Smart_Cod_Admin( $this->get_plugin_name(), $this->get_version() );350 351 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );352 353 }354 355 /**356 366 * Register all of the hooks related to the public-facing functionality 357 367 * of the plugin. -
wc-smart-cod/tags/1.8.0/wc-smart-cod.php
r3277209 r3327241 17 17 * Plugin URI: https://wordpress.org/plugins/wc-smart-cod/ 18 18 * Description: A powerful plugin that extends WooCommerce COD (Cash on Delivery) Gateway, supporting multiple extra fees and a multiple factor gateway restriction. 19 * Version: 1. 7.319 * Version: 1.8.0 20 20 * Author: woosmartcod.com 21 21 * Author URI: https://woosmartcod.com … … 25 25 * Domain Path: /languages 26 26 * WC requires at least: 2.7 27 * WC tested up to: 9. 8.127 * WC tested up to: 9.9.5 28 28 */ 29 29 -
wc-smart-cod/trunk/README.txt
r3277209 r3327241 3 3 Tags: WooCommerce, Cash on Delivery, COD, COD Extra Fee, Smart COD, WooCommerce COD, Multiple Fees 4 4 Requires at least: 3.0.1 5 Tested up to: 6.8 6 Stable tag: 1. 7.35 Tested up to: 6.8.1 6 Stable tag: 1.8.0 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
wc-smart-cod/trunk/admin/class-wc-smart-cod-admin.php
r3277209 r3327241 51 51 public $new_wc = false; 52 52 53 private $restriction_settings = array(); 54 55 private $fee_settings = array(); 56 57 private $prepared_fields = array(); 58 59 private $settings_manager = array(); 60 53 61 public function __construct() { 54 62 … … 56 64 $this->plugin_name = 'wc-smart-cod'; 57 65 $this->version = SMART_COD_VER; 66 67 $this->settings_manager = (object)Wc_Smart_Cod::get_settings_manager(); 58 68 59 69 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); 60 70 add_action( 'woocommerce_settings_api_form_fields_cod', array( $this, 'extend_cod' ) ); 61 71 add_action( 'woocommerce_settings_api_sanitized_fields_cod', array( $this, 'clean_up_settings' ) ); 72 add_filter( 'experimental_woocommerce_admin_payment_reactify_render_sections', array( $this, 'woocommerce_smart_cod') ); 62 73 add_action( 'woocommerce_delete_shipping_zone', array( $this, 'clean_up_gateway' ) ); 63 74 } … … 144 155 echo '</h2>'; 145 156 echo wp_kses_post( wpautop( $this->get_method_description() ) ); 157 146 158 $template_data = array( 147 159 'promo_texts' => WC_Smart_Cod::$promo_texts, … … 221 233 } 222 234 235 public function woocommerce_smart_cod($sections) { 236 $cod = 'cod'; 237 return array_filter($sections, function($v) use ($cod) { 238 return $v !== $cod; 239 }); 240 } 241 242 public function get_field_value($key, $field, $post_data = array()) 243 { 244 if ($this->has_prefix_in_array($key, $this->settings_manager->e)) { 245 if (!in_array($key, haystack: $this->settings_manager->d)) { 246 if (isset($this->settings[$key]) && $this->settings[$key] !== '') { 247 return $this->settings[$key]; 248 } 249 return ''; 250 } 251 } 252 return parent::get_field_value($key, $field, $post_data); 253 } 254 223 255 private function update_wc_smart_cod( $settings, $restriction_settings ) { 224 256 … … 258 290 } 259 291 292 /** 293 * Check if a string starts with any of the prefixes in an array. 294 * 295 * @param string $haystack The string to check. 296 * @param array $prefixes Array of possible prefixes. 297 * @return bool True if any prefix matches the start of the string. 298 */ 299 protected function has_prefix_in_array($haystack, $prefixes) { 300 foreach ($prefixes as $prefix) { 301 if (strncmp($haystack, $prefix, strlen($prefix)) === 0) { 302 return true; 303 } 304 } 305 return false; 306 } 307 260 308 protected function analyze_fields( $form_fields, $settings, $restriction_settings, $old_wc_smart_cod ) { 261 309 262 $fields = array();263 310 $fee_settings = array_key_exists( 'fee_settings', $settings ) ? $settings[ 'fee_settings' ] : false; 264 311 $fee_settings = $fee_settings ? json_decode( $fee_settings, true ) : array(); … … 274 321 $class_arr = explode( ' ', $field[ 'class' ] ); 275 322 323 /** 324 * - Checks if the current field has the 'wc-smart-cod-restriction' class: 325 * - Determines whether the restriction mode should be 'enable' or 'disable' based on $restriction_settings. 326 * - Updates the field title to reflect the enabled state if applicable. 327 * - Initializes restriction settings for new fields after plugin update. 328 * - Sets a custom data attribute 'data-mode' to indicate the current mode. 329 */ 276 330 if( in_array( 'wc-smart-cod-restriction', $class_arr ) ) { 277 331 // determine include or exclude … … 299 353 } 300 354 355 /* - Checks if the current field has the 'wc-smart-cod-percentage' class: 356 * - Ensures the fee type is set (defaults to 'fixed' if not present). 357 * - Marks that fee settings need to be updated if a new key is added. 358 */ 301 359 if( in_array( 'wc-smart-cod-percentage', $class_arr ) ) { 302 360 … … 311 369 } 312 370 371 if ($this->settings_manager && count($this->settings_manager->e) > 0) { 372 if ($this->has_prefix_in_array($key, $this->settings_manager->e)) { 373 374 if(!in_array($key, $this->settings_manager->d)) { 375 $needle = $this->get_dsb_key(true); 376 $form_fields[ $key ][ $this->get_dsb_key() ] = true; 377 $form_fields[ $key ][ $needle ] = $field[ $needle ] . ' wc-smart-cod-pro-field'; 378 } 379 380 } 381 } 313 382 } 314 383 … … 336 405 } 337 406 407 private function get_dsb_key( $needle = false ) { 408 return $needle ? "class" : "disabled"; 409 } 410 338 411 public function extend_cod( $form_fields ) { 339 412 $this->prepared_fields = $this->get_prepared_fields(); … … 389 462 $this->new_wc = class_exists( 'WC_Shipping_Zones' ) ? true : false; 390 463 $existing_settings = $this->settings; 391 $existing_zone_restrictions = array();392 464 $countries = new WC_Countries; 393 465 $states = $countries->get_allowed_country_states(); … … 468 540 'data-placeholder' => __( 'Select shipping zones', 'wc-smart-cod' ), 469 541 'data-name' => 'shipping_zone_restrictions' 470 ) 542 ), 543 'disabled' => false 471 544 ); 472 545 … … 483 556 'data-placeholder' => __( 'Select Countries', 'wc-smart-cod' ), 484 557 'data-name' => 'country_restrictions' 485 ) 558 ), 559 'disabled' => false 486 560 ); 487 561 … … 496 570 'data-placeholder' => __( 'Select States', 'wc-smart-cod' ), 497 571 'data-name' => 'state_restrictions' 498 ) 572 ), 573 'disabled' => false 499 574 ); 500 575 … … 506 581 'custom_attributes' => array( 507 582 'data-name' => 'restrict_postals' 508 ) 583 ), 584 'disabled' => false 509 585 ); 510 586 … … 516 592 'custom_attributes' => array( 517 593 'data-name' => 'city_restrictions' 518 ) 594 ), 595 'disabled' => false 519 596 ); 520 597 … … 527 604 'custom_attributes' => array( 528 605 'data-name' => 'cart_amount_restriction' 529 ) 606 ), 607 'disabled' => false 530 608 ); 531 609 … … 540 618 'data-placeholder' => __( 'Select Roles', 'wc-smart-cod' ), 541 619 'data-name' => 'user_role_restriction' 542 ) 620 ), 621 'disabled' => false 543 622 ); 544 623 … … 553 632 ), 554 633 'default' => 'one_product', 555 'description' => __( 'Select "at least one", if you want the COD to be restricted when at least one product of the cart belongs to a restricted category. Select "all", if you want the COD to be restricted if all the cart product\'s belongs to restricted categories. Then add the restricted categories in the select field below.', 'wc-smart-cod' ) 634 'description' => __( 'Select "at least one", if you want the COD to be restricted when at least one product of the cart belongs to a restricted category. Select "all", if you want the COD to be restricted if all the cart product\'s belongs to restricted categories. Then add the restricted categories in the select field below.', 'wc-smart-cod' ), 635 'disabled' => false 556 636 ); 557 637 … … 568 648 'data-name' => 'category_restriction', 569 649 'data-action' => 'wcsmartcod_json_search_categories' 570 ) 650 ), 651 'disabled' => false 571 652 ); 572 653 … … 581 662 ), 582 663 'default' => 'one_product', 583 'description' => __( 'Select "at least one", if you want the COD to be restricted when at least one product of the cart is restricted. Select "all", if you want the COD to be restricted if all of the cart\'s product\'s are restricted. Then add the restricted products in the select field below.', 'wc-smart-cod' ) 664 'description' => __( 'Select "at least one", if you want the COD to be restricted when at least one product of the cart is restricted. Select "all", if you want the COD to be restricted if all of the cart\'s product\'s are restricted. Then add the restricted products in the select field below.', 'wc-smart-cod' ), 665 'disabled' => false 584 666 ); 585 667 … … 596 678 'data-minimum_input_length' => '1', 597 679 'data-name' => 'product_restriction' 598 ) 680 ), 681 'disabled' => false 599 682 ); 600 683 … … 609 692 ), 610 693 'default' => 'one_product', 611 'description' => __( 'Select "at least one", if you want the COD to be restricted when at least one product of the cart belongs to a restricted shipping class. Select "all", if you want the COD to be restricted if all of the cart\'s product\'s belongs to restricted shipping classes. Then add the restricted shipping classes in the select field below.', 'wc-smart-cod' ) 694 'description' => __( 'Select "at least one", if you want the COD to be restricted when at least one product of the cart belongs to a restricted shipping class. Select "all", if you want the COD to be restricted if all of the cart\'s product\'s belongs to restricted shipping classes. Then add the restricted shipping classes in the select field below.', 'wc-smart-cod' ), 695 'disabled' => false 612 696 ); 613 697 … … 622 706 'data-placeholder' => __( 'Select Shipping Classes', 'wc-smart-cod' ), 623 707 'data-name' => 'shipping_class_restriction' 624 ) 708 ), 709 'disabled' => false 625 710 ); 626 711 … … 642 727 'type' => 'cod_messages', 643 728 'class' => 'wc-smart-cod-group', 644 'description' => __( 'An informational text to display before the payment methods, when the COD method is not available for a customer. Leave it empty if you don\'t want to use this feature. You can define different messages per reason.', 'wc-smart-cod' ) 729 'description' => __( 'An informational text to display before the payment methods, when the COD method is not available for a customer. Leave it empty if you don\'t want to use this feature. You can define different messages per reason.', 'wc-smart-cod' ), 730 'disabled' => false 645 731 ); 646 732 … … 651 737 'description' => __( 'The extra amount you charging for cash on delivery (leave blank or zero if you don\'t charge extra)', 'wc-smart-cod' ), 652 738 'desc_tip' => true, 653 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ) 739 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ), 740 'disabled' => false 654 741 ); 655 742 … … 665 752 'default' => 'round_up', 666 753 'description' => __( 'Examples: Round up setting will transform 5.345€ to 6€<br />Round down will transform it to 5€.', 'wc-smart-cod' ), 667 'desc_tip' => false 754 'desc_tip' => false, 755 'disabled' => false 668 756 ); 669 757 … … 679 767 'default' => 'disable', 680 768 'description' => __( 'Is extra fee taxable? Use this option if you have taxes enabled in your shop and you want to include tax to COD method.', 'wc-smart-cod' ), 681 'desc_tip' => false 769 'desc_tip' => false, 770 'disabled' => false 682 771 ); 683 772 … … 691 780 'custom_attributes' => array( 692 781 'data-name' => 'nocharge_amount' 693 ) 782 ), 783 'disabled' => false 694 784 ); 695 785 … … 712 802 'default' => array( 'tax', 'shipping' ), 713 803 'description' => __( 'This setting affect those settings: "Disable extra fee if cart amount is greater than this limit." and "Disable if cart amount is greater than". <strong>It defines what is finally calculated as the cart amount.</strong>', 'wc-smart-cod' ), 714 'desc_tip' => false 804 'desc_tip' => false, 805 'disabled' => false 715 806 ); 716 807 … … 724 815 'desc_tip' => true, 725 816 'class' => 'wc-smart-cod-group wc-smart-cod-percentage', 726 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ) 817 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ), 818 'disabled' => false 727 819 ); 728 820 } … … 748 840 'desc_tip' => true, 749 841 'class' => 'wc-smart-cod-group wc-smart-cod-percentage', 750 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ) 842 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ), 843 'disabled' => false 751 844 ); 752 845 … … 786 879 'desc_tip' => true, 787 880 'class' => 'wc-smart-cod-group wc-smart-cod-fee wc-smart-cod-percentage', 788 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ) 881 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ), 882 'disabled' => false 789 883 ); 790 884 … … 825 919 'desc_tip' => true, 826 920 'class' => 'wc-smart-cod-group wc-smart-cod-fee wc-smart-cod-percentage', 827 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ) 921 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ), 922 'disabled' => false 828 923 ); 829 924 } … … 838 933 $form_fields[ 'fee_settings' ] = array( 839 934 'type' => 'hidden' 935 ); 936 937 $form_fields[ 'risk_free_advance_payment' ] = array( 938 'title' => __( 'Partial payment amount for COD orders', 'wc-smart-cod' ), 939 'type' => 'price', 940 'class' => 'wc-smart-cod-group wc-smart-cod-percentage', 941 'description' => __( 'Require customers to pay a portion of the order in advance, before processing a Cash on Delivery order.', 'wc-smart-cod' ), 942 'desc_tip' => true, 943 'placeholder' => __( 'Enter Amount', 'wc-smart-cod' ), 944 'disabled' => true 840 945 ); 841 946 … … 1117 1222 unset( $settings [ $key ] ); 1118 1223 } 1119 1120 1224 } 1121 1225 … … 1194 1298 'enhanced_select' => $enhanced_select_variables, 1195 1299 'restriction_settings' => ( object ) $this->get_json_settings( 'restriction_settings' ), 1196 'fee_settings' => ( object ) $this->get_json_settings( 'fee_settings' ) 1300 'fee_settings' => ( object ) $this->get_json_settings( 'fee_settings' ), 1301 'pro_site_url' => $this->settings_manager->l 1197 1302 ); 1198 1303 -
wc-smart-cod/trunk/admin/css/wc-smart-cod-admin.css
r2918131 r3327241 92 92 } 93 93 94 .pro-badge { 95 margin: 5px 0; 96 } 97 98 .pro-badge a { 99 display: inline-block; 100 padding: 4px 10px; 101 font-size: 10px; 102 font-weight: 600; 103 color: #fff; 104 background: #403447; 105 border-radius: 999px; 106 box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); 107 letter-spacing: 0.5px; 108 user-select: none; 109 cursor: pointer; 110 text-transform: none; 111 text-decoration: none; 112 transition: all 0.2s ease-in; 113 } 114 115 .pro-badge a:hover { 116 background-color: #481c41; 117 } 118 119 .woocommerce_page_wc-settings-checkout-cod form h2 { 120 padding-top: 15px; 121 } 122 94 123 @media screen and (min-width: 1200px) { 95 124 -
wc-smart-cod/trunk/admin/js/wc-smart-cod-admin.min.js
r2376032 r3327241 1 jQuery(document).ready( function(e){var t=e("#mainform"),a=e(".woocommerce-save-button"),n=e(".wc-smart-cod-group"),c=e(".wc-smartcod-categories, .wc-smartcod-products"),r=e(".wc-smartcod-products.wc-smart-cod-group"),i=e(".wc-smart-cod-restriction"),s=e(".wc-smart-cod-percentage"),o=e("body"),d=e("#woocommerce_cod_restriction_settings"),l=e("#woocommerce_cod_fee_settings"),_=e(".wsc-message-switcher"),m=e(".wsc-message"),u={},h={};smart_cod_variables.hasOwnProperty("restriction_settings")&&(u=smart_cod_variables.restriction_settings),smart_cod_variables.hasOwnProperty("fee_settings")&&(h=smart_cod_variables.fee_settings);var p={init:function(){d.parents("tr").addClass("hidden"),l.parents("tr").addClass("hidden"),i.each(function(t,a){p.enableConditional(e(this))}),s.each(function(t,a){p.enablePercentage(e(this))}),o.on("change",".wc-smart-cod-percantage-switcher",p.switchFee),o.on("click",".wc-smart-cod-mode",p.switchMode),a.click(function(e){p.validateFields(n)||e.preventDefault()}),c.each(function(t,a){p.initSelect2(e(this))}),p.fixSelect2Bug(r),_.on("change",p.changeMessageVisibility)},changeMessageVisibility:function(t){e(this);var a=e(this).val();m.addClass("hidden"),e('.wsc-message[data-restriction="'+a+'"]').removeClass("hidden")},isObjectEmpty:function(e){var t;for(t in e)return!1;return!0},switchMode:function(t){t.preventDefault();var a=e(this),n=a.data("mode"),c="enable"===n?"disable":"enable",r=a.parents("tr").find(".wc-smart-cod-restriction").data("name");"enable"!==n&&"disable"!==n||(u[r]="enable"===c?1:0,d.val(JSON.stringify(u)),a.html(c),a.data("mode",c))},switchFee:function(t){var a=e(this),n=a.prev(),c=a.val(),r=n.attr("name");h[r.slice(16)]=c,l.val(JSON.stringify(h))},enablePercentage:function(t){var a=t.parents("fieldset"),n=e('<select class="wc-smart-cod-percantage-switcher"><option value="fixed">Fixed</option><option value="percentage">%</option></select>'),c="0",r=t.attr("name").slice(16);h.hasOwnProperty(r)?c=h[r]:h[r]=c="fixed",n.val(c),a.append(n)},enableConditional:function(e){var t=e.parents("tr").find("th").find("label");if(t.length>0){var a=t.contents().get(0).nodeValue,n=a.trim().split(" ");if(n[0]){var c=n[0].toLowerCase();switch(c){case"enable":case"disable":var r=e.attr("name"),i=e.data("name");t.contents().get(0).nodeValue=t.text().replace(a,""),n.shift(),t.prepend('<a class="wc-smart-cod-mode" href="#" data-mode="'+c+'" data-input-name="'+r+'">'+c+"</a> "+n.join(" ")),u.hasOwnProperty(i)||(u[i]="enable"===c?1:0)}}}},fixSelect2Bug:function(e){var t=e.data("select2");t&&t.on("results:message",function(e){this.dropdown._resizeDropdown(),this.dropdown._positionDropdown()})},initSelect2:function(t){var a,n=t.data("action")||"woocommerce_json_search_categories";"wcsmartcod_json_search_categories"===n?a=smart_cod_variables.enhanced_select.search_categories_nonce:"woocommerce_json_search_products_and_variations"===n&&(a=smart_cod_variables.enhanced_select.search_products_nonce);var c={allowClear:!!t.data("allow_clear"),placeholder:t.data("placeholder"),minimumInputLength:t.data("minimum_input_length")?t.data("minimum_input_length"):"3",escapeMarkup:function(e){return e},ajax:{url:smart_cod_variables.enhanced_select.ajax_url,dataType:"json",delay:250,data:function(e){return{term:e.term,action:n,security:a,exclude:t.data("exclude"),include:t.data("include"),limit:t.data("limit")}},processResults:function(t){var a=[];return t&&e.each(t,function(e,t){a.push({id:e,text:t})}),{results:a}},cache:!0}};c=e.extend(c,p.getEnhancedSelectFormatString()),t.select2(c).addClass("enhanced")},validateFields:function(a){t.find(".field-error").remove();return a.each(function(t,a){if("woocommerce_cod_include_restrict_postals"!==a.id&&"woocommerce_cod_restrict_postals"!==a.id)return!0;var n=e(this),c=n.val()?n.val().replace(/\s/g,""):n.val();n.val(c)}),!0},getEnhancedSelectFormatString:function(){return{language:{errorLoading:function(){return smart_cod_variables.enhanced_select.i18n_searching},inputTooLong:function(e){var t=e.input.length-e.maximum;return 1===t?smart_cod_variables.enhanced_select.i18n_input_too_long_1:smart_cod_variables.enhanced_select.i18n_input_too_long_n.replace("%qty%",t)},inputTooShort:function(e){var t=e.minimum-e.input.length;return 1===t?smart_cod_variables.enhanced_select.i18n_input_too_short_1:smart_cod_variables.enhanced_select.i18n_input_too_short_n.replace("%qty%",t)},loadingMore:function(){return smart_cod_variables.enhanced_select.i18n_load_more},maximumSelected:function(e){return 1===e.maximum?smart_cod_variables.enhanced_select.i18n_selection_too_long_1:smart_cod_variables.enhanced_select.i18n_selection_too_long_n.replace("%qty%",e.maximum)},noResults:function(){return smart_cod_variables.enhanced_select.i18n_no_matches},searching:function(){return smart_cod_variables.enhanced_select.i18n_searching}}}}};p.init()});1 jQuery(document).ready((function(e){var t=e("#mainform"),a=e(".woocommerce-save-button"),n=e(".wc-smart-cod-group"),r=e(".wc-smartcod-categories, .wc-smartcod-products"),i=e(".wc-smartcod-products.wc-smart-cod-group"),c=e(".wc-smart-cod-restriction"),s=e(".wc-smart-cod-percentage"),o=e("body"),d=e("#woocommerce_cod_restriction_settings"),l=e("#woocommerce_cod_fee_settings"),_=e(".wsc-message-switcher"),m=e(".wsc-message"),u=e(".wc-smart-cod-pro-field"),h={},p={},g="";smart_cod_variables.hasOwnProperty("restriction_settings")&&(h=smart_cod_variables.restriction_settings),smart_cod_variables.hasOwnProperty("fee_settings")&&(p=smart_cod_variables.fee_settings),smart_cod_variables.hasOwnProperty("pro_site_url")&&(g=smart_cod_variables.pro_site_url);var f={init:function(){d.parents("tr").addClass("hidden"),l.parents("tr").addClass("hidden"),c.each((function(t,a){f.enableConditional(e(this))})),s.each((function(t,a){f.enablePercentage(e(this))})),u.each((function(t,a){f.enableProField(e(this))})),o.on("change",".wc-smart-cod-percantage-switcher",f.switchFee),o.on("click",".wc-smart-cod-mode",f.switchMode),a.click((function(e){f.validateFields(n)||e.preventDefault()})),r.each((function(t,a){f.initSelect2(e(this))})),f.fixSelect2Bug(i),_.on("change",f.changeMessageVisibility)},changeMessageVisibility:function(t){e(this);var a=e(this).val();m.addClass("hidden"),e('.wsc-message[data-restriction="'+a+'"]').removeClass("hidden")},isObjectEmpty:function(e){var t;for(t in e)return!1;return!0},switchMode:function(t){t.preventDefault();var a=e(this),n=a.data("mode"),r="enable"===n?"disable":"enable",i=a.parents("tr").find(".wc-smart-cod-restriction").data("name");"enable"!==n&&"disable"!==n||(h[i]="enable"===r?1:0,d.val(JSON.stringify(h)),a.html(r),a.data("mode",r))},switchFee:function(t){var a=e(this),n=a.prev(),r=a.val(),i=n.attr("name");p[i.slice(16)]=r,l.val(JSON.stringify(p))},enablePercentage:function(t){var a=t.parents("fieldset"),n=e('<select class="wc-smart-cod-percantage-switcher"><option value="fixed">Fixed</option><option value="percentage">%</option></select>'),r="0",i=t.attr("name").slice(16);a.find("input").is(":disabled")&&n.prop("disabled",!0),p.hasOwnProperty(i)?r=p[i]:p[i]=r="fixed",n.val(r),a.append(n)},enableConditional:function(e){var t=e.parents("tr").find("th").find("label");if(t.length>0){var a=t.contents().get(0).nodeValue,n=a.trim().split(" ");if(n[0]){var r=n[0].toLowerCase();switch(r){case"enable":case"disable":var i=e.attr("name"),c=e.data("name");t.contents().get(0).nodeValue=t.text().replace(a,""),n.shift(),t.prepend('<a class="wc-smart-cod-mode" href="#" data-mode="'+r+'" data-input-name="'+i+'">'+r+"</a> "+n.join(" ")),h.hasOwnProperty(c)||(h[c]="enable"===r?1:0)}}}},enableProField:function(e){var t=e.parents("tr").find("th");t.length>0&&t.append('<p class="pro-badge"><a href="'+g+'" target="_blank">🚀 Available in PRO</a></p>')},fixSelect2Bug:function(e){var t=e.data("select2");t&&t.on("results:message",(function(e){this.dropdown._resizeDropdown(),this.dropdown._positionDropdown()}))},initSelect2:function(t){var a,n=t.data("action")||"woocommerce_json_search_categories";"wcsmartcod_json_search_categories"===n?a=smart_cod_variables.enhanced_select.search_categories_nonce:"woocommerce_json_search_products_and_variations"===n&&(a=smart_cod_variables.enhanced_select.search_products_nonce);var r={allowClear:!!t.data("allow_clear"),placeholder:t.data("placeholder"),minimumInputLength:t.data("minimum_input_length")?t.data("minimum_input_length"):"3",escapeMarkup:function(e){return e},ajax:{url:smart_cod_variables.enhanced_select.ajax_url,dataType:"json",delay:250,data:function(e){return{term:e.term,action:n,security:a,exclude:t.data("exclude"),include:t.data("include"),limit:t.data("limit")}},processResults:function(t){var a=[];return t&&e.each(t,(function(e,t){a.push({id:e,text:t})})),{results:a}},cache:!0}};r=e.extend(r,f.getEnhancedSelectFormatString()),t.select2(r).addClass("enhanced")},validateFields:function(a){t.find(".field-error").remove();return a.each((function(t,a){if("woocommerce_cod_include_restrict_postals"!==a.id&&"woocommerce_cod_restrict_postals"!==a.id)return!0;var n=e(this),r=n.val()?n.val().replace(/\s/g,""):n.val();n.val(r)})),!0},getEnhancedSelectFormatString:function(){return{language:{errorLoading:function(){return smart_cod_variables.enhanced_select.i18n_searching},inputTooLong:function(e){var t=e.input.length-e.maximum;return 1===t?smart_cod_variables.enhanced_select.i18n_input_too_long_1:smart_cod_variables.enhanced_select.i18n_input_too_long_n.replace("%qty%",t)},inputTooShort:function(e){var t=e.minimum-e.input.length;return 1===t?smart_cod_variables.enhanced_select.i18n_input_too_short_1:smart_cod_variables.enhanced_select.i18n_input_too_short_n.replace("%qty%",t)},loadingMore:function(){return smart_cod_variables.enhanced_select.i18n_load_more},maximumSelected:function(e){return 1===e.maximum?smart_cod_variables.enhanced_select.i18n_selection_too_long_1:smart_cod_variables.enhanced_select.i18n_selection_too_long_n.replace("%qty%",e.maximum)},noResults:function(){return smart_cod_variables.enhanced_select.i18n_no_matches},searching:function(){return smart_cod_variables.enhanced_select.i18n_searching}}}}};f.init()})); -
wc-smart-cod/trunk/includes/class-wc-smart-cod-notification-settings.php
r2985727 r3327241 17 17 $res = wp_remote_get( 18 18 $this->settings_url, 19 array( 'timeout' => 1)19 array( 'timeout' => 5, 'headers' => $headers ) 20 20 ); 21 21 … … 24 24 } 25 25 26 $ok = ( $res 27 && isset( $res['response'] ) 28 && isset( $res['response']['code'] ) 29 && $res['response']['code'] === 200 30 ); 26 $ok = $res 27 && isset($res['response']) 28 && isset($res['response']['code']) 29 && $res['response']['code'] === 200; 31 30 32 31 if($ok) { -
wc-smart-cod/trunk/includes/class-wc-smart-cod.php
r3277209 r3327241 80 80 $this->plugin_name = 'wc-smart-cod'; 81 81 82 define( 'SMART_COD_VER', '1. 7.3' );82 define( 'SMART_COD_VER', '1.8.0' ); 83 83 84 84 self::$version = SMART_COD_VER; 85 85 86 86 $this->load_notification_manager(); 87 88 $this->load_settings_manager(); 87 89 88 90 self::setup_promos(); … … 221 223 } 222 224 225 public static function get_settings_manager() { 226 227 $settings = get_transient( 'wc-smart-cod-settings' ); 228 229 if( $settings ) { 230 return $settings; 231 } 232 233 $settings_manager = new Wc_Smart_Cod_Settings_Manager( self::$pro_url ); 234 $settings = $settings_manager->get_settings_manager(); 235 236 set_transient( 'wc-smart-cod-settings', $settings, 86400 ); 237 238 return $settings; 239 } 240 223 241 public function activate_notice() { 224 242 … … 268 286 } 269 287 288 public function load_settings_manager() { 289 /** 290 * Class responsible for settings manager 291 */ 292 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc-smart-cod-settings-manager.php'; 293 } 294 270 295 public function load_dependencies() { 271 296 … … 339 364 340 365 /** 341 * Register all of the hooks related to the admin area functionality342 * of the plugin.343 *344 * @since 1.0.0345 * @access private346 */347 private function define_admin_hooks() {348 349 $plugin_admin = new Wc_Smart_Cod_Admin( $this->get_plugin_name(), $this->get_version() );350 351 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );352 353 }354 355 /**356 366 * Register all of the hooks related to the public-facing functionality 357 367 * of the plugin. -
wc-smart-cod/trunk/wc-smart-cod.php
r3277209 r3327241 17 17 * Plugin URI: https://wordpress.org/plugins/wc-smart-cod/ 18 18 * Description: A powerful plugin that extends WooCommerce COD (Cash on Delivery) Gateway, supporting multiple extra fees and a multiple factor gateway restriction. 19 * Version: 1. 7.319 * Version: 1.8.0 20 20 * Author: woosmartcod.com 21 21 * Author URI: https://woosmartcod.com … … 25 25 * Domain Path: /languages 26 26 * WC requires at least: 2.7 27 * WC tested up to: 9. 8.127 * WC tested up to: 9.9.5 28 28 */ 29 29
Note: See TracChangeset
for help on using the changeset viewer.