Changeset 3237693
- Timestamp:
- 02/10/2025 07:49:29 AM (20 months ago)
- Location:
- small-package-quotes-ups-edition
- Files:
-
- 93 added
- 1 deleted
- 29 edited
-
tags/4.5.16 (deleted)
-
tags/4.5.17 (added)
-
tags/4.5.17/css (added)
-
tags/4.5.17/css/ups-small-style.css (added)
-
tags/4.5.17/db (added)
-
tags/4.5.17/db/ups-small-db.php (added)
-
tags/4.5.17/en-hit-to-update-plan.php (added)
-
tags/4.5.17/fdo (added)
-
tags/4.5.17/fdo/en-fdo.php (added)
-
tags/4.5.17/fdo/en-sbs.php (added)
-
tags/4.5.17/fdo/freightdesk-online-section.php (added)
-
tags/4.5.17/fdo/validate-addresses-section.php (added)
-
tags/4.5.17/front (added)
-
tags/4.5.17/front/js (added)
-
tags/4.5.17/front/js/en-ups-small-checkout.js (added)
-
tags/4.5.17/helper (added)
-
tags/4.5.17/helper/en_helper_class.php (added)
-
tags/4.5.17/js (added)
-
tags/4.5.17/js/en-ups-small.js (added)
-
tags/4.5.17/js/wickedpicker.js (added)
-
tags/4.5.17/lib (added)
-
tags/4.5.17/lib/package-calculate-size.php (added)
-
tags/4.5.17/license.txt (added)
-
tags/4.5.17/logs (added)
-
tags/4.5.17/logs/en-json-tree-view (added)
-
tags/4.5.17/logs/en-json-tree-view/en-jtv-script.js (added)
-
tags/4.5.17/logs/en-json-tree-view/en-jtv-style.css (added)
-
tags/4.5.17/logs/en-json-tree-view/en-jtv.php (added)
-
tags/4.5.17/logs/en-logs.php (added)
-
tags/4.5.17/logs/en-packaging-details (added)
-
tags/4.5.17/logs/en-packaging-details/box-icon.png (added)
-
tags/4.5.17/logs/en-packaging-details/en-packaging-details.php (added)
-
tags/4.5.17/order-details (added)
-
tags/4.5.17/order-details/en-order-export.php (added)
-
tags/4.5.17/order-details/en-order-widget.php (added)
-
tags/4.5.17/order-details/rates (added)
-
tags/4.5.17/order-details/rates/order-rates.php (added)
-
tags/4.5.17/product (added)
-
tags/4.5.17/product/en-common-product-detail.php (added)
-
tags/4.5.17/product/en-product-detail.php (added)
-
tags/4.5.17/readme.txt (added)
-
tags/4.5.17/shipping-rules (added)
-
tags/4.5.17/shipping-rules/assets (added)
-
tags/4.5.17/shipping-rules/assets/css (added)
-
tags/4.5.17/shipping-rules/assets/css/shipping_rules.css (added)
-
tags/4.5.17/shipping-rules/assets/js (added)
-
tags/4.5.17/shipping-rules/assets/js/shipping_rules.js (added)
-
tags/4.5.17/shipping-rules/shipping-rules-save.php (added)
-
tags/4.5.17/shipping-rules/shipping-rules-template.php (added)
-
tags/4.5.17/small-package-quotes-ups-edition.php (added)
-
tags/4.5.17/standard-package-addon (added)
-
tags/4.5.17/standard-package-addon/instore-pickup-local-delivery (added)
-
tags/4.5.17/standard-package-addon/instore-pickup-local-delivery/instore-local-delivery.php (added)
-
tags/4.5.17/standard-package-addon/standard-package-addon.php (added)
-
tags/4.5.17/standard-package-addon/transit-days (added)
-
tags/4.5.17/standard-package-addon/transit-days/transit-days.php (added)
-
tags/4.5.17/template (added)
-
tags/4.5.17/template/connection-settings.php (added)
-
tags/4.5.17/template/csv-export.php (added)
-
tags/4.5.17/template/guide.php (added)
-
tags/4.5.17/template/products-nested-options.php (added)
-
tags/4.5.17/template/quote-settings.php (added)
-
tags/4.5.17/update-plan.php (added)
-
tags/4.5.17/ups-small-admin-filter.php (added)
-
tags/4.5.17/ups-small-auto-residential.php (added)
-
tags/4.5.17/ups-small-carrier-service.php (added)
-
tags/4.5.17/ups-small-curl-class.php (added)
-
tags/4.5.17/ups-small-group-package.php (added)
-
tags/4.5.17/ups-small-shipping-class.php (added)
-
tags/4.5.17/ups-small-tab-class.php (added)
-
tags/4.5.17/ups-small-test-connection.php (added)
-
tags/4.5.17/ups-small-wc-update-change.php (added)
-
tags/4.5.17/ups_small_version_compact.php (added)
-
tags/4.5.17/warehouse-dropship (added)
-
tags/4.5.17/warehouse-dropship/get-distance-request.php (added)
-
tags/4.5.17/warehouse-dropship/wild (added)
-
tags/4.5.17/warehouse-dropship/wild-delivery.php (added)
-
tags/4.5.17/warehouse-dropship/wild/assets (added)
-
tags/4.5.17/warehouse-dropship/wild/assets/css (added)
-
tags/4.5.17/warehouse-dropship/wild/assets/css/warehouse_section.css (added)
-
tags/4.5.17/warehouse-dropship/wild/assets/images (added)
-
tags/4.5.17/warehouse-dropship/wild/assets/images/delete.png (added)
-
tags/4.5.17/warehouse-dropship/wild/assets/images/edit.png (added)
-
tags/4.5.17/warehouse-dropship/wild/assets/images/processing.gif (added)
-
tags/4.5.17/warehouse-dropship/wild/assets/images/save.gif (added)
-
tags/4.5.17/warehouse-dropship/wild/assets/js (added)
-
tags/4.5.17/warehouse-dropship/wild/assets/js/tagging.js (added)
-
tags/4.5.17/warehouse-dropship/wild/assets/js/warehouse_section.js (added)
-
tags/4.5.17/warehouse-dropship/wild/dropship (added)
-
tags/4.5.17/warehouse-dropship/wild/dropship/dropship_template.php (added)
-
tags/4.5.17/warehouse-dropship/wild/includes (added)
-
tags/4.5.17/warehouse-dropship/wild/includes/wild-delivery-save.php (added)
-
tags/4.5.17/warehouse-dropship/wild/warehouse (added)
-
tags/4.5.17/warehouse-dropship/wild/warehouse/warehouse_template.php (added)
-
trunk/css/ups-small-style.css (modified) (2 diffs)
-
trunk/fdo/freightdesk-online-section.php (modified) (1 diff)
-
trunk/fdo/validate-addresses-section.php (modified) (1 diff)
-
trunk/js/en-ups-small.js (modified) (5 diffs)
-
trunk/logs/en-logs.php (modified) (2 diffs)
-
trunk/order-details/en-order-widget.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/shipping-rules/assets/css/shipping_rules.css (modified) (2 diffs)
-
trunk/shipping-rules/assets/js/shipping_rules.js (modified) (27 diffs)
-
trunk/shipping-rules/shipping-rules-save.php (modified) (14 diffs)
-
trunk/shipping-rules/shipping-rules-template.php (modified) (11 diffs)
-
trunk/small-package-quotes-ups-edition.php (modified) (9 diffs)
-
trunk/template/connection-settings.php (modified) (1 diff)
-
trunk/template/csv-export.php (modified) (3 diffs)
-
trunk/template/guide.php (modified) (1 diff)
-
trunk/template/products-nested-options.php (modified) (2 diffs)
-
trunk/template/quote-settings.php (modified) (1 diff)
-
trunk/update-plan.php (modified) (2 diffs)
-
trunk/ups-small-admin-filter.php (modified) (4 diffs)
-
trunk/ups-small-carrier-service.php (modified) (1 diff)
-
trunk/ups-small-group-package.php (modified) (28 diffs)
-
trunk/ups-small-shipping-class.php (modified) (4 diffs)
-
trunk/ups-small-test-connection.php (modified) (1 diff)
-
trunk/warehouse-dropship/get-distance-request.php (modified) (1 diff)
-
trunk/warehouse-dropship/wild-delivery.php (modified) (6 diffs)
-
trunk/warehouse-dropship/wild/assets/js/warehouse_section.js (modified) (13 diffs)
-
trunk/warehouse-dropship/wild/dropship/dropship_template.php (modified) (2 diffs)
-
trunk/warehouse-dropship/wild/includes/wild-delivery-save.php (modified) (9 diffs)
-
trunk/warehouse-dropship/wild/warehouse/warehouse_template.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
small-package-quotes-ups-edition/trunk/css/ups-small-style.css
r3136464 r3237693 422 422 /*estimated delivery options css*/ 423 423 tr.all_shipment_days_ups_small_tr { 424 display: inline- block;424 display: inline-table; 425 425 } 426 426 … … 640 640 padding: 0 !important; 641 641 } 642 #en-woo-review-plugin { 643 display: flex; 644 justify-content: end; 645 } 646 #en-woo-review-plugin a { 647 width: initial !important; 648 height: auto !important; 649 text-transform: initial !important; 650 font-size: unset !important; 651 } -
small-package-quotes-ups-edition/trunk/fdo/freightdesk-online-section.php
r3159756 r3237693 48 48 } 49 49 } 50 $message = wp_sprintf('<div class="user_guide_fdo ">50 $message = wp_sprintf('<div class="user_guide_fdo ups_small_wrapper"> 51 51 <h2>Connect to FreightDesk Online.</h2> 52 52 <p> -
small-package-quotes-ups-edition/trunk/fdo/validate-addresses-section.php
r3159756 r3237693 12 12 $link_freight = '<a href="https://validate-addresses.com/" target="_blank">Learn more</a>'; 13 13 $link_register = '<a href="https://validate-addresses.com/register" target="_blank">click here</a>'; 14 $message = wp_sprintf('<div class="user_guide_fdo ">14 $message = wp_sprintf('<div class="user_guide_fdo ups_small_wrapper"> 15 15 <h2>Connect to Validate Addresses.</h2> 16 16 <p> -
small-package-quotes-ups-edition/trunk/js/en-ups-small.js
r3159756 r3237693 70 70 jQuery('input[name=ups_small_delivery_estimates]').on('change', toggle_ups_delivery_estimate_label_fields); 71 71 72 // Review plugin button 73 if (jQuery('.ups_small_plan_notice').length > 0 || jQuery('.ups_small_wrapper').length > 0) { 74 const review_plugin_html = '<div id="en-woo-review-plugin"><a href="https://wordpress.org/support/plugin/small-package-quotes-ups-edition/reviews/#new-post" target="_blank" class="button button-primary is-primary">Review this plugin</a></div>'; 75 76 if (jQuery('ul.subsubsub').length > 0) { 77 jQuery('.subsubsub').after(review_plugin_html); 78 } else { 79 jQuery('li a:contains("Connection Settings")').closest('ul').after(review_plugin_html); 80 } 81 } 82 72 83 var upsSmallCurrentTime = eniture_ups_small_admin_script.ups_small_order_cutoff_time; 73 84 if (upsSmallCurrentTime != '') { … … 156 167 type: "POST", 157 168 url: ajaxurl, 158 data: { action: 'eniture_ups_small_activate_hit_to_update_plan'},169 data: { action: 'eniture_ups_small_activate_hit_to_update_plan', wp_nonce: eniture_ups_small_admin_script.nonce }, 159 170 success: function (data_response) {} 160 171 }); … … 393 404 'ups_small_license': jQuery('#ups_small_licence_key').val(), 394 405 'api_end_point': api_endpoint, 406 'wp_nonce': eniture_ups_small_admin_script.nonce 395 407 }; 396 408 … … 435 447 'action': 'ups_s_fd', 436 448 'company_id': jQuery('#freightdesk_online_id').val(), 437 'disconnect': jQuery('#fd_online_id_ups_s').attr("data") 449 'disconnect': jQuery('#fd_online_id_ups_s').attr("data"), 450 'wp_nonce': eniture_ups_small_admin_script.nonce 438 451 } 439 452 var id_lenght = jQuery('#freightdesk_online_id').val(); … … 1039 1052 type: "POST", 1040 1053 url: ajaxurl, 1041 data: { action: action},1054 data: { action: action, wp_nonce: eniture_ups_small_admin_script.nonce }, 1042 1055 success: function (data_response) { 1043 1056 window.location.reload(true); -
small-package-quotes-ups-edition/trunk/logs/en-logs.php
r3219695 r3237693 68 68 $logs = (!empty($logs) && is_string($logs) && strlen($logs) > 0) ? json_decode($logs, true) : []; 69 69 70 echo '<table class="en_logs">'; 70 // Eniture debug mode 71 do_action('eniture_debug_mode', 'UPS Small Logs', $logs); 72 73 echo '<table class="en_logs ups_small_wrapper">'; 71 74 72 75 if (isset($logs['severity'], $logs['data']) && $logs['severity'] == 'SUCCESS') { … … 207 210 } 208 211 209 echo '< table>';212 echo '</table>'; 210 213 } 211 214 -
small-package-quotes-ups-edition/trunk/order-details/en-order-widget.php
r3159756 r3237693 35 35 case 'en_fdo_meta_data': 36 36 $en_widget_details = json_decode($meta_data->value, true); 37 38 // Eniture debug mode 39 do_action("eniture_debug_mood", "Order Widget Details (UPS Small)", $en_widget_details); 40 37 41 if (!empty($en_widget_details)) { 38 42 $this->en_widget_details[] = $en_widget_details; … … 168 172 'liftgate' => 'Lift gate delivery', 169 173 'hazmat' => 'Hazardous Material', 170 'holdatterminal' => 'Hold At Terminal' 174 'holdatterminal' => 'Hold At Terminal', 175 'limitedaccess' => 'Limited access delivery', 176 'liftgate_pickup' => 'Lift gate pickup', 171 177 ]; 172 178 -
small-package-quotes-ups-edition/trunk/readme.txt
r3222153 r3237693 4 4 Requires at least: 6.6 5 5 Tested up to: 6.7.1 6 Stable tag: 4.5.1 66 Stable tag: 4.5.17 7 7 License: GPL-2.0-or-later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 143 143 == Changelog == 144 144 145 = 4.5.17 = 146 * Update: Added a new "Review Plugin" button for improved user feedback and engagement. 147 * Update: Override Rates Shipping Rule: added Negative & Percentage Service Rate. 148 * Update: Restrict To Location Rule: Introduced filters support. 149 * Update: Minimum Shipping Charge Rule: Implemented a new rule to set a minimum charge for shipping. 150 * Update: Free Shipping Rule: Added functionality to allow free shipping conditions based on configured rules. 151 * Fix: Export Products Functionality: Fixed issues with old nested material attributes of products to ensure accurate exports. 152 * Fix:Security Enhancements: Resolved vulnerability issues for improved plugin security and compliance. 153 * Fix:Request Parameters Sanitization: Improved sanitization in shipping rules to enhance data integrity 154 155 145 156 = 4.5.16 = 146 157 * Fix: Fixed order the shipping rule "Type" alphabetically. -
small-package-quotes-ups-edition/trunk/shipping-rules/assets/css/shipping_rules.css
r3219695 r3237693 18 18 .en_sr_form_control #en_ups_small_filter_by_state_label, 19 19 .en_sr_form_control #en_ups_small_filter_by_origin_label, 20 .en_sr_form_control #en_ups_small_filter_by_sevices_label { 20 .en_sr_form_control #en_ups_small_filter_by_sevices_label, 21 .en_sr_form_control #en_ups_small_msc_filter_by_sevices_label { 21 22 margin-bottom: -15px !important; 22 23 } … … 46 47 47 48 label[for='en_sr_service_name']::after, 48 label[for='en_ sr_service_rate']::after,49 label[for='en_ups_small_sr_service_rate']::after, 49 50 label[for='en_ups_small_filter_by_state']::after, 50 51 label[for='en_ups_small_filter_by_origin']::after, 51 label[for='en_ups_small_filter_by_sevices']::after { 52 label[for='en_ups_small_filter_by_sevices']::after, 53 label[for='en_ups_small_msc_filter_by_sevices']::after, 54 label[for='en_sr_minimum_shipping_charge']::after { 52 55 content: ' *'; 53 56 color: red; -
small-package-quotes-ups-edition/trunk/shipping-rules/assets/js/shipping_rules.js
r3219695 r3237693 9 9 10 10 const rule_types = { 11 free_shipping: 'Free Shipping', 11 12 hide_methods: 'Hide Methods', 13 hide_methods_by_origin_location: 'Hide Methods By Origin', 14 large_cart_settings: 'Large Cart Settings', 15 minimum_shipping_charge: 'Minimum Shipping Charge', 12 16 override_rates: 'Override Rates', 13 17 restrict_to_state: 'Restrict To State', 14 large_cart_settings: 'Large Cart Settings',15 hide_methods_by_origin_location: 'Hide Methods By Origin',16 18 }; 17 19 … … 28 30 'en_sr_product_tags_list', 29 31 'en_sr_service_name', 30 'en_ sr_service_rate',32 'en_ups_small_sr_service_rate', 31 33 'en_sr_max_items', 32 34 'en_sr_max_weight_per_package' … … 43 45 jQuery('.en_ups_small_sr_locations_list #en_sr_locations_list').val([]); 44 46 jQuery('.en_ups_small_sr_services_list #en_sr_services_list').val([]); 47 // Override rates 48 jQuery('#en_ups_small_or_sr_country').val(''); 49 jQuery('.en_ups_small_or_sr_us_states_list #en_or_sr_states_list').val([]); 50 jQuery('.en_ups_small_or_sr_ca_states_list #en_or_sr_states_list').val([]); 51 // Minimum shipping charge 52 jQuery('.en_ups_small_msc_sr_services_list #en_msc_sr_services_list').val([]); 45 53 46 54 enUpsSmalltoggleRuleTypeFields(); 55 56 // Restrict to state 47 57 enUpsSmallToggleCountryStates(); 48 58 enUpsSmallSetStatesValidation(false, true); 59 60 // Override rates shipping rule 61 enUpsSmallORToggleCountryStates(); 49 62 }); 50 63 … … 52 65 53 66 jQuery( 54 '#en_sr_weight_from, #en_sr_weight_to, #en_sr_price_from, #en_sr_price_to, #en_sr_ service_rate, #en_sr_max_items, #en_sr_max_weight_per_package'67 '#en_sr_weight_from, #en_sr_weight_to, #en_sr_price_from, #en_sr_price_to, #en_sr_max_items, #en_sr_max_weight_per_package, #en_sr_minimum_shipping_charge' 55 68 ).keypress(function (e) { 56 69 if (!String.fromCharCode(e.keyCode).match(/^[0-9.]+$/)) return false; … … 59 72 if (!String.fromCharCode(e.keyCode).match(/^[0-9]+$/)) return false; 60 73 }); 61 74 jQuery('#en_ups_small_sr_service_rate').keypress(function (e) { 75 if (!String.fromCharCode(e.keyCode).match(/^[0-9.%+-]+$/)) return false; 76 }); 77 78 // Restrict to state 62 79 enUpsSmallToggleCountryStates(); 63 80 jQuery('#en_ups_small_sr_country').on('change load', function() { … … 66 83 }); 67 84 85 // Override rates shipping rule 86 enUpsSmallORToggleCountryStates(); 87 jQuery('#en_ups_small_or_sr_country').on('change load', enUpsSmallORToggleCountryStates); 88 jQuery('#filter_by_country_or').on('change', function () { 89 !this.checked && jQuery('#filter_by_state_or').prop('checked', false); 90 }); 91 jQuery('#filter_by_state_or').on('change', function () { 92 this.checked && jQuery('#filter_by_country_or').prop('checked', true); 93 }); 94 68 95 jQuery('#en_ups_small_filter_by_country').on('change load', function () { 69 96 // if country is unchecked, then uncheck state also 70 97 if (!this.checked) jQuery('#en_ups_small_filter_by_state').prop('checked', false); 71 98 }); 72 73 99 jQuery('#en_ups_small_filter_by_state').on('change', function () { 74 100 this.checked && jQuery('#en_ups_small_filter_by_country').prop('checked', this.checked); … … 222 248 function enUpsSmallSaveShippingRule(e) { 223 249 e.preventDefault(); 250 jQuery('.en_ups_small_sr_form .en_sr_err').html(''); 224 251 225 252 let is_valid = enUpsSmallSRValidateInput('#add_shipping_rule'); … … 234 261 } 235 262 263 // apply required field validations for override rates rule 264 if (rule_type === rule_types.override_rates) { 265 const validate = enUpsSmallORValidations(); 266 is_valid = is_valid && validate; 267 } 268 236 269 // apply required field validations for hide methods by origin location rule 237 270 if (rule_type === rule_types.hide_methods_by_origin_location) { … … 240 273 } 241 274 275 // apply required field validations for minimum shipping charge rule 276 if (rule_type === rule_types.minimum_shipping_charge) { 277 const validate = enUpsSmallMSCValidations(); 278 is_valid = is_valid && validate; 279 } 280 242 281 if (!is_valid) { 243 282 jQuery('.content').delay(200).animate({ scrollTop: 0 }, 300); … … 251 290 const origins_value = hide_methods_by_origin_rule ? jQuery('.en_ups_small_sr_locations_list #en_sr_locations_list').val() : []; 252 291 const services_value = hide_methods_by_origin_rule ? jQuery('.en_ups_small_sr_services_list #en_sr_services_list').val() : []; 292 // Override rates rule 293 const or_rule = rule_type === rule_types.override_rates; 294 let or_states_values = []; 295 or_states_values = jQuery('#en_ups_small_or_sr_country').val() === 'US' ? jQuery('.en_ups_small_or_sr_us_states_list #en_or_sr_states_list').val(): or_states_values; 296 or_states_values = jQuery('#en_ups_small_or_sr_country').val() === 'CA' ? jQuery('.en_ups_small_or_sr_ca_states_list #en_or_sr_states_list').val(): or_states_values; 297 // Minimum shipping charge rule 298 const msc_rule = rule_type === rule_types.minimum_shipping_charge; 253 299 254 300 // Submit the form to save settings 255 301 const postData = { 256 302 action: 'en_save_shipping_rule', 303 wp_nonce: sr_script.nonce, 257 304 rule_id: jQuery('#edit_sr_form_id').val(), 258 305 name: jQuery('#en_sr_rule_name').val(), … … 260 307 is_active: Number(jQuery('#en_sr_avialable').prop('checked')), 261 308 settings: { 262 filter_name: [rule_types.hide_methods, rule_types.override_rates].includes(rule_type) ? jQuery('#en_sr_filter_name').val() :'',309 filter_name: '', 263 310 apply_to: jQuery('input[name="apply_to"]:checked').val(), 264 311 // Filter by country … … 284 331 filter_by_product_tag_value: jQuery('#en_sr_product_tags_list').val(), 285 332 // Service info 286 service: jQuery('#en_sr_service_name').val(),287 service_rate: jQuery('#en_sr_service_rate').val(),333 service: or_rule ? jQuery('#en_sr_service_name').val() : '', 334 service_rate: or_rule ? jQuery('#en_ups_small_sr_service_rate').val() : '', 288 335 // Large cart settings 289 336 max_items: jQuery('#en_sr_max_items').val(), … … 294 341 filter_by_service: hide_methods_by_origin_rule, 295 342 filter_by_service_value: hide_methods_by_origin_rule ? services_value : [], 343 // Override rates country and state filters 344 filter_by_country_or: or_rule ? jQuery('#filter_by_country_or').prop('checked') : false, 345 filter_by_country_value_or: or_rule ? jQuery('#en_ups_small_or_sr_country').val() : '', 346 filter_by_state_or: or_rule ? jQuery('#filter_by_state_or').prop('checked') : false, 347 filter_by_state_value_or: or_rule ? or_states_values : [], 348 // Minimum shipping charge 349 minimum_shipping_charge: msc_rule ? jQuery('#en_sr_minimum_shipping_charge').val() : '', 350 minimum_shipping_charge_services: msc_rule ? jQuery('#en_msc_sr_services_list').val() : [], 296 351 }, 297 352 }; … … 359 414 jQuery('.en_ups_small_sr_locations_list #en_sr_locations_list').val([]); 360 415 jQuery('.en_ups_small_sr_services_list #en_sr_services_list').val([]); 416 jQuery('.en_ups_small_msc_sr_services_list #en_msc_sr_services_list').val([]); 361 417 362 418 const postForm = { 363 419 action: 'en_edit_shipping_rule', 364 420 edit_id: rule_id, 421 wp_nonce: sr_script.nonce, 365 422 }; 366 423 … … 374 431 jQuery(elem).css( 375 432 'background', 376 `rgba(255, 255, 255, 1) url("${s cript.pluginsUrl}/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/processing.gif") no-repeat scroll 50% 50%`433 `rgba(255, 255, 255, 1) url("${sr_script.pluginsUrl}/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/processing.gif") no-repeat scroll 50% 50%` 377 434 ); 378 435 }, … … 382 439 383 440 if (data) { 384 jQuery('#edit_sr_form_id').val(data?.rule_data.id); 385 jQuery('#en_sr_rule_name').val(data?.rule_data?.name); 386 jQuery('#en_ups_small_rule_type').val(data?.rule_data?.type); 387 jQuery('#en_sr_avialable').prop( 388 'checked', 389 Number(data?.rule_data?.is_active) 390 ); 391 392 enUpsSmalltoggleRuleTypeFields(); 393 394 const settings = JSON.parse(data?.rule_data?.settings) ?? {}; 395 396 jQuery('input[name="apply_to"]').val([settings?.apply_to]); 397 jQuery('#en_sr_filter_name').val(settings?.filter_name); 398 // Override rates 399 jQuery('#en_sr_service_name').val(settings?.service); 400 jQuery('#en_sr_service_rate').val(settings?.service_rate); 401 // Large cart settings 402 jQuery('#en_sr_max_items').val(settings?.max_items); 403 jQuery('#en_sr_max_weight_per_package').val( 404 settings?.max_weight_per_package 405 ); 406 407 // Restrict to state 408 if (jQuery('#en_ups_small_rule_type').val() === rule_types.restrict_to_state) { 409 jQuery('#en_ups_small_filter_by_country').prop('checked', settings?.filter_by_country === 'true'); 410 jQuery('#en_ups_small_sr_country').val(settings?.filter_by_country_value || 'US'); 411 jQuery('#en_ups_small_filter_by_state').prop('checked', settings?.filter_by_state === 'true'); 412 enUpsSmallSetStatesValidation(true, false); 413 414 if (data?.country_states_markup) { 415 const countryId = settings?.filter_by_country_value; 416 jQuery(countryId === 'US' ? '.en_ups_small_sr_us_states_list #en_sr_states_list' : '.en_ups_small_sr_ca_states_list #en_sr_states_list').html(data?.country_states_markup).trigger('change'); 417 } 418 419 enUpsSmallToggleCountryStates(); 420 } 421 422 // Hide methods by origin location 423 if (jQuery('#en_ups_small_rule_type').val() === rule_types.hide_methods_by_origin_location) { 424 jQuery('#filter_by_origin').prop('checked', settings?.filter_by_origin === 'true'); 425 jQuery('.en_ups_small_sr_locations_list #en_sr_locations_list').html(data?.origins_markup).trigger('change'); 426 427 jQuery("#filter_by_service").prop('checked', settings?.filter_by_service === 'true'); 428 jQuery('.en_ups_small_sr_services_list #en_sr_services_list').html(data?.services_markup).trigger('change'); 429 } 430 431 // Common filters settings 432 jQuery('#filter_by_weight').prop( 433 'checked', 434 settings?.filter_by_weight === 'true' 435 ); 436 settings?.filter_by_weight === 'true' && 437 removeDataAttribute('en_sr_weight_from'); 438 jQuery('#en_sr_weight_from').val(settings?.filter_by_weight_from); 439 jQuery('#en_sr_weight_to').val(settings?.filter_by_weight_to); 440 jQuery('#en_sr_filter_price').prop( 441 'checked', 442 settings?.filter_by_price === 'true' 443 ); 444 settings?.filter_by_price === 'true' && 445 removeDataAttribute('en_sr_price_from'); 446 jQuery('#en_sr_price_from').val(settings?.filter_by_price_from); 447 jQuery('#en_sr_price_to').val(settings?.filter_by_price_to); 448 jQuery('#filter_by_quantity').prop( 449 'checked', 450 settings?.filter_by_quantity === 'true' 451 ); 452 settings?.filter_by_quantity === 'true' && 453 removeDataAttribute('en_sr_quantity_from'); 454 jQuery('#en_sr_quantity_from').val(settings?.filter_by_quantity_from); 455 jQuery('#en_sr_quantity_to').val(settings?.filter_by_quantity_to); 456 jQuery('#filter_by_product_tag').prop( 457 'checked', 458 settings?.filter_by_product_tag === 'true' 459 ); 460 settings?.filter_by_product_tag === 'true' && 461 removeDataAttribute('en_sr_product_tags_list'); 462 jQuery('#en_sr_product_tags_list') 463 .html(data?.product_tags_markup) 464 .trigger('change'); 441 enUpsSmallSRPopulateData(data); 465 442 jQuery('.content').animate({ scrollTop: 0 }, 0); 466 443 … … 493 470 action: 'en_delete_shipping_rule', 494 471 delete_id: id, 472 wp_nonce: sr_script.nonce, 495 473 }; 496 474 … … 504 482 jQuery(elem).css( 505 483 'background', 506 `rgba(255, 255, 255, 1) url("${s cript.pluginsUrl}/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/processing.gif") no-repeat scroll 50% 50%`484 `rgba(255, 255, 255, 1) url("${sr_script.pluginsUrl}/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/processing.gif") no-repeat scroll 50% 50%` 507 485 ); 508 486 }, … … 535 513 rule_id, 536 514 is_active: Number(!Number(is_active)), 515 wp_nonce: sr_script.nonce, 537 516 }; 538 517 … … 546 525 jQuery(elem).css( 547 526 'background', 548 `rgba(255, 255, 255, 1) url("${s cript.pluginsUrl}/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/processing.gif") no-repeat scroll 50% 50%`527 `rgba(255, 255, 255, 1) url("${sr_script.pluginsUrl}/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/processing.gif") no-repeat scroll 50% 50%` 549 528 ); 550 529 }, … … 573 552 <td class="en_wd_warehouse_list_data">${rule?.name}</td> 574 553 <td class="en_wd_warehouse_list_data">${rule?.type}</td> 575 <td class="en_wd_warehouse_list_data">${rule?.settings?.filter_name}</td>576 554 <td class="en_wd_warehouse_list_data"><a href="#" class='en_ups_sr_status_link' data-id='${ 577 555 rule?.id … … 581 559 <a href="#" class="en_ups_sr_edit_link" data-id="${rule?.id}"> 582 560 <img src="${ 583 s cript.pluginsUrl561 sr_script.pluginsUrl 584 562 }/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/edit.png" title="Edit"> 585 563 </a> … … 587 565 <a href="#" class="en_ups_sr_delete_link" data-id="${rule?.id}"> 588 566 <img src="${ 589 s cript.pluginsUrl567 sr_script.pluginsUrl 590 568 }/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/delete.png" title="Delete"> 591 569 </a> … … 601 579 jQuery('#en_ups_small_sr_content').css('height', '80vh'); 602 580 enUpsSmallSetStatesValidation(false, true); 581 jQuery('.en_sr_hide_methods_by_origin_location, .en_ups_small_sr_large_cart_settings, .en_sr_min_shipping_charge, .en_sr_override_rates, .en_sr_restrict_to_state, #en_sr_apply_to_product').hide(); 603 582 604 583 if (type === rule_types.override_rates) { 605 jQuery('.en_sr_override_rates, .en_ups_small_sr_apply_to, #en_sr_apply_to_shipment, .en_ups_small_sr_filters_section ').show();606 jQuery('#en_sr_apply_to_cart , .en_sr_restrict_to_state, .en_ups_small_sr_large_cart_settings, .en_sr_hide_methods_by_origin_location').hide();584 jQuery('.en_sr_override_rates, .en_ups_small_sr_apply_to, #en_sr_apply_to_shipment, .en_ups_small_sr_filters_section, .en_or_sr_filters').show(); 585 jQuery('#en_sr_apply_to_cart').hide(); 607 586 jQuery('input[name="apply_to"]').val(['shipment']); 608 587 609 588 setDataAttribute('en_sr_max_items', 'en_sr_max_weight_per_package'); 610 removeDataAttribute('en_sr_service_name', 'en_ sr_service_rate');589 removeDataAttribute('en_sr_service_name', 'en_ups_small_sr_service_rate'); 611 590 } else if (type === rule_types.restrict_to_state) { 612 jQuery('.en_ups_small_sr_apply_to, #en_sr_apply_to_cart, .en_sr_restrict_to_state ').show();591 jQuery('.en_ups_small_sr_apply_to, #en_sr_apply_to_cart, .en_sr_restrict_to_state, .en_ups_small_sr_filters_section').show(); 613 592 jQuery('input[name="apply_to"]').val(['cart']); 614 jQuery(' .en_sr_override_rates, #en_sr_apply_to_shipment, .en_ups_small_sr_large_cart_settings, .en_sr_hide_methods_by_origin_location, .en_ups_small_sr_filters_section').hide();615 616 setDataAttribute('en_sr_service', 'en_ sr_service_rate', 'en_sr_max_items', 'en_sr_max_weight_per_package');593 jQuery('#en_sr_apply_to_shipment, .en_or_sr_filters').hide(); 594 595 setDataAttribute('en_sr_service', 'en_ups_small_sr_service_rate', 'en_sr_max_items', 'en_sr_max_weight_per_package'); 617 596 enUpsSmallSetStatesValidation(); 618 597 } else if (type === rule_types.large_cart_settings) { 619 jQuery('.en_ sr_override_rates, .en_ups_small_sr_apply_to, .en_sr_restrict_to_state, .en_sr_hide_methods_by_origin_location, .en_ups_small_sr_filters_section').hide();598 jQuery('.en_ups_small_sr_apply_to, .en_ups_small_sr_filters_section, .en_or_sr_filters').hide(); 620 599 jQuery('.en_ups_small_sr_large_cart_settings').show(); 621 600 jQuery('input[name="apply_to"]').val(['cart']); 622 601 623 setDataAttribute('en_sr_service_name', 'en_ sr_service_rate');602 setDataAttribute('en_sr_service_name', 'en_ups_small_sr_service_rate'); 624 603 removeDataAttribute('en_sr_max_items', 'en_sr_max_weight_per_package'); 625 604 } else if (type === rule_types.hide_methods_by_origin_location) { 626 605 jQuery('.en_ups_small_sr_apply_to, #en_sr_apply_to_shipment, .en_sr_hide_methods_by_origin_location').show(); 627 jQuery(' .en_sr_override_rates, #en_sr_apply_to_cart, .en_sr_restrict_to_state, .en_ups_small_sr_large_cart_settings, .en_ups_small_sr_filters_section').hide();606 jQuery('#en_sr_apply_to_cart, .en_ups_small_sr_filters_section, .en_or_sr_filters').hide(); 628 607 jQuery('input[name="apply_to"]').val(['shipment']); 629 608 630 setDataAttribute('en_sr_service_name', 'en_ sr_service_rate', 'en_sr_max_items', 'en_sr_max_weight_per_package');609 setDataAttribute('en_sr_service_name', 'en_ups_small_sr_service_rate', 'en_sr_max_items', 'en_sr_max_weight_per_package'); 631 610 removeDataAttribute('en_sr_locations_list, en_sr_services_list'); 611 } else if (type === rule_types.minimum_shipping_charge) { 612 jQuery('.en_or_sr_filters').hide(); 613 jQuery('.en_ups_small_sr_apply_to, #en_sr_apply_to_cart, #en_sr_apply_to_shipment, .en_sr_min_shipping_charge, .en_ups_small_sr_filters_section').show(); 614 jQuery('input[name="apply_to"]').val(['shipment']); 615 616 setDataAttribute('en_sr_service_name', 'en_ups_small_sr_service_rate', 'en_sr_max_items', 'en_sr_max_weight_per_package'); 617 removeDataAttribute('en_sr_minimum_shipping_charge', 'en_msc_sr_services_list'); 632 618 } else { 633 jQuery('.en_sr_override_rates, .en_sr_restrict_to_state, .en_ups_small_sr_large_cart_settings, .en_sr_hide_methods_by_origin_location').hide(); 634 jQuery('.en_ups_small_sr_apply_to, #en_sr_apply_to_cart, #en_sr_apply_to_shipment, .en_ups_small_sr_filters_section').show(); 635 jQuery('input[name="apply_to"]').val(['cart']); 636 637 setDataAttribute('en_sr_service_name', 'en_sr_service_rate', 'en_sr_max_items', 'en_sr_max_weight_per_package'); 619 jQuery('.en_or_sr_filters').hide(); 620 621 if (type === rule_types.free_shipping) { 622 jQuery('#en_sr_apply_to_cart, #en_sr_apply_to_shipment').hide(); 623 jQuery('.en_ups_small_sr_apply_to, #en_sr_apply_to_product, .en_ups_small_sr_filters_section').show(); 624 jQuery('input[name="apply_to"]').val(['product']); 625 } else { 626 jQuery('#en_sr_apply_to_product').hide(); 627 jQuery('.en_ups_small_sr_apply_to, #en_sr_apply_to_cart, #en_sr_apply_to_shipment, .en_ups_small_sr_filters_section').show(); 628 jQuery('input[name="apply_to"]').val(['cart']); 629 } 630 631 setDataAttribute('en_sr_service_name', 'en_ups_small_sr_service_rate', 'en_sr_max_items', 'en_sr_max_weight_per_package', 'en_sr_locations_list', 'en_sr_services_list', 'en_sr_minimum_shipping_charge', 'en_msc_sr_services_list'); 638 632 } 639 633 } … … 657 651 } 658 652 659 // #region Toggle country states 653 // #region Toggle country states (Restrict to State rule) 660 654 function enUpsSmallToggleCountryStates() { 661 655 const selectedCountry = jQuery('#en_ups_small_sr_country').val(); … … 664 658 } 665 659 660 // #region Toggle country states (Override rates rule) 661 function enUpsSmallORToggleCountryStates() { 662 const selectedCountry = jQuery('#en_ups_small_or_sr_country').val(); 663 664 if (!selectedCountry) { 665 jQuery('.en_ups_small_or_sr_us_states_list #en_or_sr_states_list').val([]); 666 jQuery('.en_ups_small_or_sr_ca_states_list #en_or_sr_states_list').val([]); 667 } 668 669 jQuery('.en_ups_small_or_empty_sr_states_list').css('display', !selectedCountry ? '' : 'none'); 670 jQuery('.en_ups_small_or_sr_us_states_list').css('display', selectedCountry === 'US' ? '' : 'none'); 671 jQuery('.en_ups_small_or_sr_ca_states_list').css('display', selectedCountry === 'CA' ? '' : 'none'); 672 } 673 674 // #region: Hide Methods by Origin Location Validations 666 675 function enUpsSmallHMBLValidations() { 667 676 const ids = ['#en_sr_locations_list', '#en_sr_services_list']; … … 679 688 return is_valid; 680 689 } 690 691 // #region: Override Rates Validations 692 function enUpsSmallORValidations() { 693 let is_valid = true; 694 695 // Filter by country 696 if (jQuery('#filter_by_country_or').prop('checked') && !jQuery('#en_ups_small_or_sr_country').val()) { 697 jQuery('#en_ups_small_or_sr_country').parent().find('.en_sr_err').html('Country is required.'); 698 is_valid = false; 699 } 700 701 // Filter by state 702 if (jQuery('#filter_by_state_or').prop('checked')) { 703 const selectedCountry = jQuery('#en_ups_small_or_sr_country').val(), 704 us_states_value = jQuery('.en_ups_small_or_sr_us_states_list #en_or_sr_states_list').val(), 705 ca_states_value = jQuery('.en_ups_small_or_sr_ca_states_list #en_or_sr_states_list').val(), 706 parent_elem = '.en_ups_small_or_empty_sr_states_list, .en_ups_small_or_sr_us_states_list, .en_ups_small_or_sr_ca_states_list'; 707 708 if (!selectedCountry || (selectedCountry === 'US' && !us_states_value?.length) || 709 (selectedCountry === 'CA' && !ca_states_value?.length)) { 710 jQuery(parent_elem).find('.en_sr_err').html('State is required.'); 711 is_valid = false; 712 } 713 } 714 715 return is_valid; 716 } 717 718 // #region: Populate Shipping Rule Data 719 function enUpsSmallSRPopulateData(data) { 720 jQuery('#edit_sr_form_id').val(data?.rule_data.id); 721 jQuery('#en_sr_rule_name').val(data?.rule_data?.name); 722 jQuery('#en_ups_small_rule_type').val(data?.rule_data?.type); 723 jQuery('#en_sr_avialable').prop( 724 'checked', 725 Number(data?.rule_data?.is_active) 726 ); 727 728 enUpsSmalltoggleRuleTypeFields(); 729 730 const settings = JSON.parse(data?.rule_data?.settings) ?? {}; 731 732 jQuery('input[name="apply_to"]').val([settings?.apply_to]); 733 // Override rates 734 jQuery('#en_sr_service_name').val(settings?.service); 735 jQuery('#en_ups_small_sr_service_rate').val(settings?.service_rate); 736 // Large cart settings 737 jQuery('#en_sr_max_items').val(settings?.max_items); 738 jQuery('#en_sr_max_weight_per_package').val( 739 settings?.max_weight_per_package 740 ); 741 742 const rule_type = jQuery('#en_ups_small_rule_type').val(); 743 744 // Hide methods by origin location 745 if (rule_type === rule_types.hide_methods_by_origin_location) { 746 jQuery('#filter_by_origin').prop('checked', settings?.filter_by_origin === 'true'); 747 jQuery('.en_ups_small_sr_locations_list #en_sr_locations_list').html(data?.origins_markup).trigger('change'); 748 749 jQuery("#filter_by_service").prop('checked', settings?.filter_by_service === 'true'); 750 jQuery('.en_ups_small_sr_services_list #en_sr_services_list').html(data?.services_markup).trigger('change'); 751 } 752 753 // Minimum shipping charge 754 if (rule_type === rule_types.minimum_shipping_charge) { 755 jQuery('#en_sr_minimum_shipping_charge').val(settings?.minimum_shipping_charge); 756 jQuery('.en_ups_small_msc_sr_services_list #en_msc_sr_services_list').html(data?.services_markup).trigger('change'); 757 } 758 759 // Override rates 760 if (rule_type === rule_types.override_rates) { 761 jQuery('#filter_by_country_or').prop('checked', settings?.filter_by_country_or === 'true'); 762 jQuery('#en_ups_small_or_sr_country').val(settings?.filter_by_country_value_or); 763 jQuery('#filter_by_state_or').prop('checked', settings?.filter_by_state_or === 'true'); 764 765 if (data?.or_country_states_markup) { 766 const country = settings?.filter_by_country_value_or; 767 jQuery(!country && '.en_ups_small_or_empty_sr_states_list #en_or_empty_sr_states_list').html('').trigger('change'); 768 jQuery(country === 'US' && '.en_ups_small_or_sr_us_states_list #en_or_sr_states_list').html(data?.or_country_states_markup).trigger('change'); 769 jQuery(country === 'CA' && '.en_ups_small_or_sr_ca_states_list #en_or_sr_states_list').html(data?.or_country_states_markup).trigger('change'); 770 } 771 772 enUpsSmallORToggleCountryStates(); 773 } 774 775 // Restrict to state 776 if (rule_type === rule_types.restrict_to_state) { 777 jQuery('#en_ups_small_filter_by_country').prop('checked', settings?.filter_by_country === 'true'); 778 jQuery('#en_ups_small_sr_country').val(settings?.filter_by_country_value || 'US'); 779 jQuery('#en_ups_small_filter_by_state').prop('checked', settings?.filter_by_state === 'true'); 780 enUpsSmallSetStatesValidation(true, false); 781 782 if (data?.country_states_markup) { 783 const countryId = settings?.filter_by_country_value; 784 jQuery(countryId === 'US' ? '.en_ups_small_sr_us_states_list #en_sr_states_list' : '.en_ups_small_sr_ca_states_list #en_sr_states_list').html(data?.country_states_markup).trigger('change'); 785 } 786 787 enUpsSmallToggleCountryStates(); 788 } 789 790 // Common filters settings 791 // Weight 792 jQuery('#filter_by_weight').prop('checked', settings?.filter_by_weight === 'true'); 793 settings?.filter_by_weight === 'true' && removeDataAttribute('en_sr_weight_from'); 794 jQuery('#en_sr_weight_from').val(settings?.filter_by_weight_from); 795 jQuery('#en_sr_weight_to').val(settings?.filter_by_weight_to); 796 // Price 797 jQuery('#en_sr_filter_price').prop('checked', settings?.filter_by_price === 'true'); 798 settings?.filter_by_price === 'true' && removeDataAttribute('en_sr_price_from'); 799 jQuery('#en_sr_price_from').val(settings?.filter_by_price_from); 800 jQuery('#en_sr_price_to').val(settings?.filter_by_price_to); 801 // Quantity 802 jQuery('#filter_by_quantity').prop('checked', settings?.filter_by_quantity === 'true'); 803 settings?.filter_by_quantity === 'true' && removeDataAttribute('en_sr_quantity_from'); 804 jQuery('#en_sr_quantity_from').val(settings?.filter_by_quantity_from); 805 jQuery('#en_sr_quantity_to').val(settings?.filter_by_quantity_to); 806 // Product tags 807 jQuery('#filter_by_product_tag').prop('checked', settings?.filter_by_product_tag === 'true'); 808 settings?.filter_by_product_tag === 'true' && removeDataAttribute('en_sr_product_tags_list'); 809 jQuery('#en_sr_product_tags_list').html(data?.product_tags_markup).trigger('change'); 810 } 811 812 // #region: Minimum Shipping Charge Validations 813 function enUpsSmallMSCValidations() { 814 let is_valid = true; 815 816 if (!jQuery('.en_ups_small_msc_sr_services_list #en_msc_sr_services_list').val()?.length) { 817 jQuery('.en_ups_small_msc_sr_services_list').find('.en_sr_err').html('Services is required.'); 818 is_valid = false; 819 } 820 821 return is_valid; 822 } 681 823 }); -
small-package-quotes-ups-edition/trunk/shipping-rules/shipping-rules-save.php
r3219695 r3237693 37 37 function save_shipping_rule_ajax() 38 38 { 39 if (!current_user_can('manage_options') || !wp_verify_nonce($_POST['wp_nonce'], 'en_woo_sr_nonce')) { 40 echo wp_json_encode([]); 41 return; 42 } 43 39 44 global $wpdb; 40 45 … … 42 47 $error = false; 43 48 $data = $_POST; 44 $get_shipping_rule_id = (isset($data['rule_id']) && intval($data['rule_id'])) ? $data['rule_id'] : ""; 49 $data = $this->sanitize_request_data($data); 50 $get_shipping_rule_id = (isset($data['rule_id']) && intval($data['rule_id'])) ? intval($data['rule_id']) : ""; 45 51 $last_id = $get_shipping_rule_id; 46 52 $get_shipping_rule = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "eniture_ups_small_shipping_rules WHERE name = %s", $data['name'])); 47 53 unset($data['action']); 48 54 unset($data['rule_id']); 49 55 unset($data['wp_nonce']); 56 50 57 if (!empty($get_shipping_rule_id)) { 51 58 $data['settings'] = wp_json_encode($data['settings']); … … 78 85 function edit_shipping_rule_ajax() 79 86 { 80 global $wpdb; 81 $get_shipping_rule_id = (isset($_POST['edit_id']) && intval($_POST['edit_id'])) ? sanitize_text_field(wp_unslash($_POST['edit_id'])) : ""; 87 if (!current_user_can('manage_options') || !wp_verify_nonce($_POST['wp_nonce'], 'en_woo_sr_nonce')) { 88 echo wp_json_encode([]); 89 return; 90 } 91 92 global $wpdb; 93 $get_shipping_rule_id = (isset($_POST['edit_id']) && intval($_POST['edit_id'])) ? intval($_POST['edit_id']) : ""; 82 94 $shipping_rules_list = $wpdb->get_results( 83 95 "SELECT * FROM " . $wpdb->prefix . "eniture_ups_small_shipping_rules WHERE id=$get_shipping_rule_id" 84 96 ); 97 $shipping_rules_type = isset(reset($shipping_rules_list)->type) ? reset($shipping_rules_list)->type : ''; 98 85 99 $product_tags_markup = $this->get_product_tags_markup($shipping_rules_list); 86 100 $states_markup = $this->get_country_states_markup($shipping_rules_list); 87 101 $origins_markup = $this->get_origins_markup($shipping_rules_list); 88 $services_markup = $this->get_services_markup($shipping_rules_list); 89 90 $data = ['rule_data' => reset($shipping_rules_list), 'product_tags_markup' => $product_tags_markup, 'country_states_markup' => $states_markup, 'origins_markup' => $origins_markup, 'services_markup' => $services_markup]; 102 $services_markup = $this->get_services_markup($shipping_rules_list, $shipping_rules_type); 103 // override rates rule 104 $or_states_markup = $shipping_rules_type == 'Override Rates' ? $this->get_country_states_markup($shipping_rules_list, true) : ''; 105 106 $data = ['rule_data' => reset($shipping_rules_list), 'product_tags_markup' => $product_tags_markup, 'country_states_markup' => $states_markup, 'origins_markup' => $origins_markup, 'services_markup' => $services_markup, 'or_country_states_markup' => $or_states_markup,]; 91 107 92 108 echo wp_json_encode($data); … … 101 117 function delete_shipping_rule_ajax() 102 118 { 103 global $wpdb; 104 $get_shipping_rule_id = (isset($_POST['delete_id']) && intval($_POST['delete_id'])) ? sanitize_text_field(wp_unslash($_POST['delete_id'])) : ""; 119 if (!current_user_can('manage_options') || !wp_verify_nonce($_POST['wp_nonce'], 'en_woo_sr_nonce')) { 120 echo wp_json_encode([]); 121 return; 122 } 123 124 global $wpdb; 125 $get_shipping_rule_id = (isset($_POST['delete_id']) && intval($_POST['delete_id'])) ? intval($_POST['delete_id']) : ""; 105 126 $qry = $wpdb->delete($wpdb->prefix . 'eniture_ups_small_shipping_rules', array('id' => $get_shipping_rule_id)); 106 127 … … 116 137 function update_shipping_rule_status_ajax() 117 138 { 118 global $wpdb; 119 $get_shipping_rule_id = (isset($_POST['rule_id']) && intval($_POST['rule_id'])) ? sanitize_text_field(wp_unslash($_POST['rule_id'])) : ""; 139 if (!current_user_can('manage_options') || !wp_verify_nonce($_POST['wp_nonce'], 'en_woo_sr_nonce')) { 140 echo wp_json_encode([]); 141 return; 142 } 143 144 global $wpdb; 145 $get_shipping_rule_id = (isset($_POST['rule_id']) && intval($_POST['rule_id'])) ? intval($_POST['rule_id']) : ""; 120 146 $is_active = isset($_POST['is_active']) ? sanitize_text_field(wp_unslash($_POST['is_active'])) : ""; 121 147 $data = ['is_active' => $is_active]; 122 148 123 149 $update_qry = $wpdb->update( 124 150 $wpdb->prefix . 'eniture_ups_small_shipping_rules', $data, array('id' => $get_shipping_rule_id) … … 199 225 * @global $wpdb 200 226 */ 201 function get_country_states_markup($shipping_rules_list )227 function get_country_states_markup($shipping_rules_list, $override_rates_rule = false) 202 228 { 203 229 $states_options = ''; 204 230 $shipping_rules_list = reset($shipping_rules_list); 205 231 $settings = isset($shipping_rules_list->settings) ? json_decode($shipping_rules_list->settings, true) : []; 206 $selected_states_detials = $this->get_selected_states_details($settings); 232 $filter_by_state_val = $override_rates_rule ? 'filter_by_state_value_or' : 'filter_by_state_value'; 233 $filter_by_country_val = $override_rates_rule ? 'filter_by_country_value_or' : 'filter_by_country_value'; 234 $selected_states_detials = $this->get_selected_states_details($settings, $filter_by_state_val, $filter_by_country_val); 207 235 208 236 if (!empty($selected_states_detials) && is_array($selected_states_detials)) { … … 212 240 } 213 241 214 if (empty($settings[ 'filter_by_state_value']) || !is_array($settings['filter_by_state_value'])) {215 $settings[ 'filter_by_state_value'] = [];242 if (empty($settings[$filter_by_state_val]) || !is_array($settings[$filter_by_state_val])) { 243 $settings[$filter_by_state_val] = []; 216 244 } 217 245 218 246 $countries_obj = new WC_Countries(); 219 $selected_country = isset($settings[ 'filter_by_country_value']) ? $settings['filter_by_country_value'] : '';247 $selected_country = isset($settings[$filter_by_country_val]) ? $settings[$filter_by_country_val] : ''; 220 248 $en_woo_states = $countries_obj->get_states($selected_country); 221 249 222 if (!empty($en_woo_states) && is_array($settings[ 'filter_by_state_value'])) {250 if (!empty($en_woo_states) && is_array($settings[$filter_by_state_val])) { 223 251 foreach ($en_woo_states as $s_code => $s_label) { 224 if (!in_array($s_code, $settings[ 'filter_by_state_value'])) {252 if (!in_array($s_code, $settings[$filter_by_state_val])) { 225 253 $states_options .= "<option value='" . esc_attr($s_code) . "'>" . esc_html($s_label) . "</option>"; 226 254 } … … 236 264 * @global $wpdb 237 265 */ 238 function get_selected_states_details($settings )239 { 240 $states_arr = isset($settings[ 'filter_by_state_value']) ? $settings['filter_by_state_value'] : [];266 function get_selected_states_details($settings, $filter_by_state_val, $filter_by_country_val) 267 { 268 $states_arr = isset($settings[$filter_by_state_val]) ? $settings[$filter_by_state_val] : []; 241 269 if (empty($states_arr) || !is_array($states_arr)) { 242 270 return []; … … 244 272 245 273 $countries_obj = new WC_Countries(); 246 $selected_country = isset($settings[ 'filter_by_country_value']) ? $settings['filter_by_country_value'] : '';274 $selected_country = isset($settings[$filter_by_country_val]) ? $settings[$filter_by_country_val] : ''; 247 275 $en_woo_states = $countries_obj->get_states($selected_country); 248 276 $states_detail = []; … … 306 334 } 307 335 308 function get_services_markup($shipping_rules_list )336 function get_services_markup($shipping_rules_list, $type) 309 337 { 310 338 $services_options = ''; … … 312 340 $settings = isset($shipping_rules_list->settings) ? json_decode($shipping_rules_list->settings, true) : []; 313 341 $services = $this->get_all_services(); 314 $selected_services_detials = $this->get_selected_services_details($settings, $services );342 $selected_services_detials = $this->get_selected_services_details($settings, $services, $type); 315 343 316 344 if (!empty($selected_services_detials) && is_array($selected_services_detials)) { … … 320 348 } 321 349 322 if (empty($settings['filter_by_service_value']) || !is_array($settings['filter_by_service_value'])) { 323 $settings['filter_by_service_value'] = []; 350 $filter_by_service = $type == 'Hide Methods By Origin' ? 'filter_by_service_value' : 'minimum_shipping_charge_services'; 351 if (empty($settings[$filter_by_service]) || !is_array($settings[$filter_by_service])) { 352 $settings[$filter_by_service] = []; 324 353 } 325 354 326 355 foreach ($services as $key => $service) { 327 if (in_array($key, $settings[ 'filter_by_service_value'])) continue;356 if (in_array($key, $settings[$filter_by_service])) continue; 328 357 $services_options .= "<option value='" . esc_attr($key) . "'>" . esc_html($service) . "</option>"; 329 358 } … … 332 361 } 333 362 334 function get_selected_services_details($settings, $services) 335 { 336 $services_arr = isset($settings['filter_by_service_value']) ? $settings['filter_by_service_value'] : []; 363 function get_selected_services_details($settings, $services, $type) 364 { 365 $filter_by_service = $type == 'Hide Methods By Origin' ? 'filter_by_service_value' : 'minimum_shipping_charge_services'; 366 $services_arr = isset($settings[$filter_by_service]) ? $settings[$filter_by_service] : []; 337 367 if (empty($services_arr) || !is_array($services_arr)) return []; 338 368 … … 380 410 return $response; 381 411 } 412 413 function ups_small_get_service_rate($net_rate, $settings, $min_ship_charge) 414 { 415 $service_rate = $settings['service_rate']; 416 if ($min_ship_charge) { 417 $min_shipping_rate = isset($settings['minimum_shipping_charge']) ? $settings['minimum_shipping_charge'] : 0; 418 419 return $net_rate < $min_shipping_rate ? $min_shipping_rate : $net_rate; 420 } 421 422 if (strpos($service_rate, '%') === false) return $service_rate; 423 424 // Calculate the percentage of service rate based on net rate and add it to net rate 425 $service_rate = str_replace('%', '', $service_rate) / 100; 426 $service_rate = floatval($net_rate) * floatval($service_rate); 427 $net_rate = floatval($net_rate) + floatval($service_rate); 428 429 return $net_rate; 430 } 431 432 function apply_free_shipping_rule($ups_small_package) 433 { 434 if (empty($ups_small_package)) return []; 435 436 global $wpdb; 437 $rules = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "eniture_ups_small_shipping_rules"), ARRAY_A); 438 if (empty($rules)) return []; 439 440 $filtered_products_ids = []; 441 442 // check if free shipping rule exists 443 foreach ($rules as $rule) { 444 if (!$rule['is_active'] || $rule['type'] != 'Free Shipping') continue; 445 446 // Eniture debug mode 447 do_action("eniture_debug_mood", "UPS Small Free Shipping Rule", $rule); 448 449 $products = []; 450 $product_tags = []; 451 foreach ($ups_small_package as $package) { 452 if (!isset($package['items']) || empty($package['items'])) continue; 453 454 $products = array_merge($products, $package['items']); 455 $product_tags = isset($package['product_tags']) && !empty($package['product_tags']) ? array_merge($product_tags, $package['product_tags']) : $product_tags; 456 } 457 458 if (empty($products)) return []; 459 460 $settings = isset($rule['settings']) ? json_decode($rule['settings'], true) : []; 461 $filters_checks = ['filter_by_weight', 'filter_by_price', 'filter_by_quantity', 'filter_by_product_tag']; 462 $any_filter_checked = false; 463 464 foreach ($filters_checks as $check) { 465 if (isset($settings[$check]) && filter_var($settings[$check], FILTER_VALIDATE_BOOLEAN)) { 466 $any_filter_checked = true; 467 break; 468 } 469 } 470 471 if (!$any_filter_checked) { 472 $rates = array( 473 'id' => 'ups_small:' . 'free', 474 'label' => 'Free Shipping', 475 'cost' => 0, 476 'plugin_name' => 'upsSmall', 477 'plugin_type' => 'small', 478 'owned_by' => 'eniture' 479 ); 480 481 return $rates; 482 } 483 484 $is_filter_applied = false; 485 $filters = ['weight', 'price', 'quantity', 'product_tag']; 486 $count = 0; 487 488 foreach ($products as $product) { 489 $is_filter_applied = false; 490 $qty = isset($product['productQty']) ? $product['productQty'] : 1; 491 492 $product['quantity'] = $qty; 493 $product['weight'] = isset($product['productWeight']) ? $product['productWeight'] * $qty : 1; 494 $product['price'] = isset($product['productPrice']) ? $product['productPrice'] * $qty : 1; 495 496 foreach ($filters as $filter) { 497 if (isset($settings['filter_by_' . $filter]) && filter_var($settings['filter_by_' . $filter], FILTER_VALIDATE_BOOLEAN)) { 498 if ($filter == 'product_tag') { 499 $product_id = isset($product['variantId']) && $product['variantId'] > 0 ? $product['variantId'] : $product['productId']; 500 $parent_id = wp_get_post_parent_id($product_id); 501 $product_tags = get_the_terms($product_id, 'product_tag'); 502 $product_tags = empty($product_tags) ? get_the_terms($parent_id, 'product_tag') : $product_tags; 503 $product_tag_ids = empty($product_tags) || !is_array($product_tags) ? [] : array_map(function($tag) { return $tag->term_id; }, $product_tags); 504 505 if (isset($settings['filter_by_product_tag']) && filter_var($settings['filter_by_product_tag'], FILTER_VALIDATE_BOOLEAN)) { 506 $rule_tags = $settings['filter_by_product_tag_value']; 507 $tags_check = array_filter($rule_tags, function ($tag) use ($product_tag_ids) { 508 return in_array($tag, $product_tag_ids); 509 }); 510 $is_filter_applied = count($tags_check) > 0; 511 } 512 } else { 513 $is_filter_applied = $product[$filter] >= $settings['filter_by_' . $filter . '_from']; 514 if ($is_filter_applied && !empty($settings['filter_by_' . $filter . '_to'])) { 515 $is_filter_applied = $product[$filter] < $settings['filter_by_' . $filter . '_to']; 516 } 517 } 518 } 519 520 if ($is_filter_applied) break; 521 } 522 523 if ($is_filter_applied) { 524 $count++; 525 $filtered_products_ids[] = $product['productId']; 526 } 527 } 528 529 // If all products match the filter, return free shipping 530 if ($is_filter_applied && $count == count($products)) { 531 $rates = array( 532 'id' => 'ups_small:' . 'free', 533 'label' => 'Free Shipping', 534 'cost' => 0, 535 'plugin_name' => 'upsSmall', 536 'plugin_type' => 'small', 537 'owned_by' => 'eniture' 538 ); 539 540 return [ 541 'rates' => $rates, 542 'package' => $ups_small_package 543 ]; 544 } 545 } 546 547 if (!empty($filtered_products_ids)) { 548 foreach ($ups_small_package as $key => $package) { 549 foreach ($package['items'] as $ik => $item) { 550 if (in_array($item['productId'], $filtered_products_ids)) { 551 unset($ups_small_package[$key]['items'][$ik]); 552 } 553 } 554 } 555 } 556 557 return [ 558 'rates' => [], 559 'package' => $ups_small_package 560 ]; 561 } 562 563 function sanitize_request_data($data) 564 { 565 if (empty($data)) return $data; 566 567 if (is_array($data)) { 568 foreach ($data as $key => $value) { 569 if (is_array($value)) { 570 $data[$key] = $this->sanitize_request_data($value); 571 } else { 572 $data[$key] = isset($value) ? esc_attr(sanitize_text_field( wp_unslash($value) )) : ''; 573 } 574 } 575 } else { 576 $data = isset($data) ? esc_attr(sanitize_text_field( wp_unslash($data) )) : ''; 577 } 578 579 return $data; 580 } 382 581 } 383 582 } -
small-package-quotes-ups-edition/trunk/shipping-rules/shipping-rules-template.php
r3222153 r3237693 16 16 "SELECT * FROM " . $wpdb->prefix . "eniture_ups_small_shipping_rules" 17 17 ); 18 19 // Eniture debug mode 20 do_action("eniture_debug_mood", "UPS Small Shipping Rules", $shipping_rules_list); 18 21 19 22 ?> … … 30 33 </th> 31 34 <th class="en_wd_warehouse_list_heading"> 32 Filters33 </th>34 <th class="en_wd_warehouse_list_heading">35 35 Available 36 36 </th> … … 48 48 foreach ($shipping_rules_list as $rule) { 49 49 $rule->settings = !empty($rule->settings) ? json_decode($rule->settings) : []; 50 $filter_name = in_array($rule->type, ['Hide Methods', 'Override Rates']) && isset($rule->settings->filter_name) ? $rule->settings->filter_name : ''; 50 $rule_type = isset($rule->type) ? $rule->type : ''; 51 $rule_type = $rule_type == 'Hide Methods By Origin' ? 'Hide Methods By Origin Location' : $rule_type; 51 52 52 53 ?> 53 54 <tr id="sr_row_<?php echo (isset($rule->id)) ? esc_attr($rule->id) : ''; ?>" class="en_ups_sr_row"> 54 55 <td class="en_wd_warehouse_list_data"><?php echo esc_attr($rule->name); ?></td> 55 <td class="en_wd_warehouse_list_data"><?php echo esc_attr($rule->type); ?></td> 56 <td class="en_wd_warehouse_list_data"><?php echo esc_attr($filter_name); ?></td> 56 <td class="en_wd_warehouse_list_data"><?php echo esc_attr($rule_type); ?></td> 57 57 <td class="en_wd_warehouse_list_data"> 58 58 <a href="#" class="en_ups_sr_status_link" data-id="<?php echo (isset($rule->id)) ? esc_attr($rule->id) : ''; ?>" data-status="<?php echo esc_attr($rule->is_active); ?>"><?php echo esc_attr($rule->is_active) ? 'Yes' : 'No'; ?></a> … … 106 106 107 107 <!-- Shipping rules html markup --> 108 <div class="en_shipping_rules_setting_section ">108 <div class="en_shipping_rules_setting_section ups_small_wrapper"> 109 109 <br /> 110 110 <!-- Add rule button --> … … 128 128 129 129 <!-- Add popup for new rule --> 130 <div id="en_wd_add_warehouse_btn" class="en_wd_warehouse_overlay ">130 <div id="en_wd_add_warehouse_btn" class="en_wd_warehouse_overlay en_ups_small_sr_popup"> 131 131 <div class="en_wd_add_warehouse_popup"> 132 132 <h2 class="warehouse_heading">Add Rule</h2> … … 141 141 142 142 <!-- Add shipping rule form --> 143 <form id="add_shipping_rule" role="form">143 <form id="add_shipping_rule" class="en_ups_small_sr_form" role="form"> 144 144 <input type="hidden" name="edit_sr_form_id" value="" id="edit_sr_form_id"> 145 145 <!-- Rule name --> … … 154 154 <label for="en_ups_small_rule_type">Type</label> 155 155 <select name="en_ups_small_rule_type" id="en_ups_small_rule_type" title="Type"> 156 <option value="Free Shipping">Free Shipping</option> 156 157 <option value="Hide Methods">Hide Methods</option> 157 158 <option value="Hide Methods By Origin">Hide Methods By Origin Location</option> 158 159 <option value="Large Cart Settings">Large Cart Settings</option> 160 <option value="Minimum Shipping Charge">Minimum Shipping Charge</option> 159 161 <option value="Override Rates">Override Rates</option> 160 162 <option value="Restrict To State">Restrict To State</option> … … 174 176 <input type="radio" name="apply_to" value="shipment" title="Shipment"> <span>Shipment</span> 175 177 </div> 176 <span class="en_sr_err"></span> 177 </div> 178 178 <div id="en_sr_apply_to_product"> 179 <div><p></p></div> 180 <input type="radio" name="apply_to" value="product" title="Product"> <span>Product</span> 181 </div> 182 <span class="en_sr_err"></span> 183 </div> 184 185 <!-- Hide methods by origin location section --> 186 <div class="en_sr_hide_methods_by_origin_location"> 187 <!-- Filter by Origins --> 188 <div class="en_sr_form_control"> 189 <label for="en_ups_small_filter_by_origin" id="en_ups_small_filter_by_origin_label"> 190 Origins 191 </label> 192 </div> 193 194 <!-- Origins list --> 195 <div class="en_sr_form_control en_ups_small_sr_locations_list"> 196 <select name="en_sr_locations_list" id="en_sr_locations_list" multiple="multiple" data-attribute="en_location_list_value" data-optional="1" class="chosen_select en_location_list_value" style="width: 100% !important;" title="Origins"> 197 <?php 198 global $wpdb; 199 $warehouse_table = $wpdb->prefix . "warehouse"; 200 $locations = $wpdb->get_results("SELECT * FROM $warehouse_table", ARRAY_A); 201 202 if (isset($locations) && !empty($locations)) { 203 foreach ($locations as $key => $value) { 204 $location = $value['city'] . ' ' . $value['state'] . ' ' . $value['zip'] . ', ' . $value['country']; 205 echo "<option value='" . esc_attr($value['zip']) . "'>" . esc_html($location) . "</option>"; 206 } 207 } 208 ?> 209 </select> 210 <span class="en_sr_err"></span> 211 <span class="descrption"> 212 Shipping methods for the services listed below will be hidden for customers from these origins. 213 </span> 214 </div> 215 216 <!-- Filter by Services --> 217 <div class="en_sr_form_control"> 218 <label for="en_ups_small_filter_by_sevices" id="en_ups_small_filter_by_sevices_label"> 219 Services 220 </label> 221 </div> 222 223 <!-- Services list --> 224 <div class="en_sr_form_control en_ups_small_sr_services_list"> 225 <select name="en_sr_services_list" id="en_sr_services_list" multiple="multiple" data-attribute="en_service_list_value" data-optional="1" class="chosen_select en_service_list_value" style="width: 100% !important;" title="Services"> 226 <?php 227 $services = eniture_shipping_rules_get_services_list(); 228 foreach ($services as $key => $value) { 229 echo "<option value='" . esc_attr($key) . "'>" . esc_html('UPS ' . $value) . "</option>"; 230 } 231 ?> 232 </select> 233 <span class="en_sr_err"></span> 234 </div> 235 </div> 236 237 <!-- Large cart settings section --> 238 <div class="en_ups_small_sr_large_cart_settings"> 239 <div class="en_sr_form_control"> 240 <p> 241 The packaging algorithm identifies the ideal packaging solution via an iterative process. If the Cart contains a large number of items, the time the packaging algorithm requires to identify the ideal packaging solution can exceed the window of time WordPress allows for shipping quotes to be returned. In these cases, the packaging algorithm needs to be bypassed. Use the settings below to specify your preferences for when the packaging algorithm is to be bypassed. Test the results to make sure results (shipping quotes) are returned when a large number of items is in the Cart. The number of boxes you define and the diversity of the items in your product catalog will influence the time the packaging algorithm requires. Therefore, your settings will differ from those of other merchants. 242 </p> 243 </div> 244 245 <div class="en_sr_form_control"> 246 <label for="en_sr_max_items">Max items <span style="color: red;">*</span></label> 247 <input type="text" title="Max items" name="en_sr_max_items" id="en_sr_max_items" data-optional="1" maxlength="10"> 248 <span class="en_sr_err"></span> 249 <p class="description">When the Cart contains more than this number of items, the packaging algorithm will be bypassed and rates will be calculated exclusively on the basis of weight.</p> 250 </div> 251 252 <div class="en_sr_form_control"> 253 <label for="en_sr_max_weight_per_package">Max weight per package <span style="color: red;">*</span></label> 254 <input type="text" title="Max weight per package" name="en_sr_max_weight_per_package" id="en_sr_max_weight_per_package" data-optional="1" maxlength="10"> 255 <span class="en_sr_err"></span> 256 <p class="description">Specify the maximum weight allowed per package when the packaging algorithm is bypassed. The maximum permitted value is 150 LB.</p> 257 </div> 258 </div> 259 260 <!-- Minimum shipping charge section --> 261 <div class="en_sr_min_shipping_charge"> 262 <!-- Minimum shipping charge --> 263 <div class="en_sr_form_control"> 264 <label for="en_sr_minimum_shipping_charge">Minimum Shipping Rate</label> 265 <input type="text" title="Minimum shipping charge" name="en_sr_minimum_shipping_charge" id="en_sr_minimum_shipping_charge" data-optional="1" maxlength="7"> 266 267 <span class="en_sr_err"></span> 268 <span class="descrption"> 269 Enter the min. shipping rate to show on checkout. 270 </span> 271 </div> 272 273 <div class="en_sr_form_control"> 274 <label for="en_ups_small_msc_filter_by_sevices" id="en_ups_small_msc_filter_by_sevices_label"> 275 Services 276 </label> 277 </div> 278 279 <!-- Services list --> 280 <div class="en_sr_form_control en_ups_small_msc_sr_services_list"> 281 <select name="en_msc_sr_services_list" id="en_msc_sr_services_list" multiple="multiple" data-attribute="en_service_list_value" data-optional="1" class="chosen_select en_service_list_value" style="width: 100% !important;" title="Services"> 282 <?php 283 $services = eniture_shipping_rules_get_services_list(); 284 foreach ($services as $key => $value) { 285 echo "<option value='" . esc_attr($key) . "'>" . esc_html('UPS ' . $value) . "</option>"; 286 } 287 ?> 288 </select> 289 <span class="en_sr_err"></span> 290 </div> 291 </div> 292 179 293 <!-- Override rates section --> 180 294 <div class="en_sr_override_rates"> … … 197 311 <!-- Service rate --> 198 312 <div class="en_sr_form_control"> 199 <label for="en_ sr_service_rate">Service rate (e.g. 5.25)</label>200 <input type="text" title="Service rate" name="en_ sr_service_rate" id="en_sr_service_rate" data-optional="1" maxlength="10" data-optional="1">313 <label for="en_ups_small_sr_service_rate">Service rate</label> 314 <input type="text" title="Service rate" name="en_ups_small_sr_service_rate" id="en_ups_small_sr_service_rate" data-optional="1" maxlength="10" data-optional="1" placeholder="Enter amount or percentage (e.g. 10, -5, 20%)"> 201 315 <span class="en_sr_err"></span> 202 316 </div> … … 265 379 </div> 266 380 267 <!-- Large cart settings section -->268 <div class="en_ups_small_sr_large_cart_settings">269 <div class="en_sr_form_control">270 <p>271 The packaging algorithm identifies the ideal packaging solution via an iterative process. If the Cart contains a large number of items, the time the packaging algorithm requires to identify the ideal packaging solution can exceed the window of time WordPress allows for shipping quotes to be returned. In these cases, the packaging algorithm needs to be bypassed. Use the settings below to specify your preferences for when the packaging algorithm is to be bypassed. Test the results to make sure results (shipping quotes) are returned when a large number of items is in the Cart. The number of boxes you define and the diversity of the items in your product catalog will influence the time the packaging algorithm requires. Therefore, your settings will differ from those of other merchants.272 </p>273 </div>274 275 <div class="en_sr_form_control">276 <label for="en_sr_max_items">Max items <span style="color: red;">*</span></label>277 <input type="text" title="Max items" name="en_sr_max_items" id="en_sr_max_items" data-optional="1" maxlength="10">278 <span class="en_sr_err"></span>279 <p class="description">When the Cart contains more than this number of items, the packaging algorithm will be bypassed and rates will be calculated exclusively on the basis of weight.</p>280 </div>281 282 <div class="en_sr_form_control">283 <label for="en_sr_max_weight_per_package">Max weight per package <span style="color: red;">*</span></label>284 <input type="text" title="Max weight per package" name="en_sr_max_weight_per_package" id="en_sr_max_weight_per_package" data-optional="1" maxlength="10">285 <span class="en_sr_err"></span>286 <p class="description">Specify the maximum weight allowed per package when the packaging algorithm is bypassed. The maximum permitted value is 150 LB.</p>287 </div>288 </div>289 290 <!-- Hide methods by origin location section -->291 <div class="en_sr_hide_methods_by_origin_location">292 <!-- Filter by Origins -->293 <div class="en_sr_form_control">294 <label for="en_ups_small_filter_by_origin" id="en_ups_small_filter_by_origin_label">295 Origins296 </label>297 </div>298 299 <!-- Origins list -->300 <div class="en_sr_form_control en_ups_small_sr_locations_list">301 <select name="en_sr_locations_list" id="en_sr_locations_list" multiple="multiple" data-attribute="en_location_list_value" data-optional="1" class="chosen_select en_location_list_value" style="width: 100% !important;" title="Origins">302 <?php303 global $wpdb;304 $warehouse_table = $wpdb->prefix . "warehouse";305 $locations = $wpdb->get_results("SELECT * FROM $warehouse_table", ARRAY_A);306 307 if (isset($locations) && !empty($locations)) {308 foreach ($locations as $key => $value) {309 $location = $value['city'] . ' ' . $value['state'] . ' ' . $value['zip'] . ', ' . $value['country'];310 echo "<option value='" . esc_attr($value['zip']) . "'>" . esc_html($location) . "</option>";311 }312 }313 ?>314 </select>315 <span class="en_sr_err"></span>316 <span class="descrption">317 Shipping methods for the services listed below will be hidden for customers from these origins.318 </span>319 </div>320 321 <!-- Filter by Services -->322 <div class="en_sr_form_control">323 <label for="en_ups_small_filter_by_sevices" id="en_ups_small_filter_by_sevices_label">324 Services325 </label>326 </div>327 328 <!-- Services list -->329 <div class="en_sr_form_control en_ups_small_sr_services_list">330 <select name="en_sr_services_list" id="en_sr_services_list" multiple="multiple" data-attribute="en_service_list_value" data-optional="1" class="chosen_select en_service_list_value" style="width: 100% !important;" title="Services">331 <?php332 $services = eniture_shipping_rules_get_services_list();333 foreach ($services as $key => $value) {334 echo "<option value='" . esc_attr($key) . "'>" . esc_html('UPS ' . $value) . "</option>";335 }336 ?>337 </select>338 <span class="en_sr_err"></span>339 </div>340 </div>341 342 381 <!-- Filters section --> 343 382 <div class="en_ups_small_sr_filters_section"> 344 <!-- Filter name -->345 <div class="en_sr_form_control">346 <label for="en_sr_filter_name">Filter Name</label>347 <input type="text" title="Filter Name" name="en_sr_filter_name" id="en_sr_filter_name" data-optional="1" maxlength="50">348 <span class="en_sr_err"></span>349 </div>350 351 383 <!-- Filter by Weight --> 352 384 <div class="en_sr_form_control"> … … 446 478 </div> 447 479 480 <!-- Override Rates Filters --> 481 <div class="en_or_sr_filters"> 482 <!-- Filter by Country --> 483 <section> 484 <div class="en_sr_form_control"> 485 <div> 486 <label for="filter_by_country_or"> 487 <input type="checkbox" title="Filter by country" name="filter_by_country_or" id="filter_by_country_or"> Filter by country 488 </label> 489 </div> 490 </div> 491 <!-- Country list --> 492 <div class="en_sr_form_control"> 493 <select name="en_ups_small_or_sr_country" id="en_ups_small_or_sr_country" title="Countries"> 494 <option value="">Select One</option> 495 <option value="US">US</option> 496 <option value="CA">CA</option> 497 </select> 498 499 <span class="en_sr_err"></span> 500 </div> 501 </section> 502 503 <!-- Filter by State --> 504 <section> 505 <div class="en_sr_form_control"> 506 <div> 507 <label for="filter_by_state_or"> 508 <input type="checkbox" title="Filter by state" name="filter_by_state_or" id="filter_by_state_or"> Filter by state 509 </label> 510 </div> 511 <span class="en_sr_err"></span> 512 </div> 513 514 <!-- US States list --> 515 <div class="en_sr_form_control en_ups_small_or_sr_us_states_list"> 516 <select name="en_or_sr_states_list" id="en_or_sr_states_list" multiple="multiple" data-attribute="en_state_list_value" data-optional="1" class="chosen_select en_state_list_value" style="width: 100% !important;" title="States/Provinces"> 517 <?php 518 global $woocommerce; 519 $countries_obj = new WC_Countries(); 520 $us_states = $countries_obj->get_states('US'); 521 522 if (isset($us_states) && !empty($us_states)) { 523 foreach ($us_states as $key => $value) { 524 echo "<option class='or_us_state' value='" . esc_attr($key) . "'>" . esc_html($value) . "</option>"; 525 } 526 } 527 ?> 528 </select> 529 530 <span class="en_sr_err"></span> 531 <span class="descrption"> 532 Only customers from these states/provinces will be presented with shipping rates for this provider. 533 </span> 534 </div> 535 536 <!-- CA States list --> 537 <div class="en_sr_form_control en_ups_small_or_sr_ca_states_list"> 538 <select name="en_or_sr_states_list" id="en_or_sr_states_list" multiple="multiple" data-attribute="en_state_list_value" data-optional="1" class="chosen_select en_state_list_value" style="width: 100% !important;" title="States/Provinces"> 539 <?php 540 global $woocommerce; 541 $countries_obj = new WC_Countries(); 542 $ca_states = $countries_obj->get_states('CA'); 543 544 if (isset($ca_states) && !empty($ca_states)) { 545 foreach ($ca_states as $key => $value) { 546 echo "<option class='or_ca_state' value='" . esc_attr($key) . "'>" . esc_html($value) . "</option>"; 547 } 548 } 549 ?> 550 </select> 551 552 <span class="en_sr_err"></span> 553 <span class="descrption"> 554 Only customers from these states/provinces will be presented with shipping rates for this provider. 555 </span> 556 </div> 557 558 <!-- Empty states list --> 559 <div class="en_sr_form_control en_ups_small_or_empty_sr_states_list"> 560 <select name="en_or_empty_sr_states_list" id="en_or_empty_sr_states_list" multiple="multiple" data-attribute="en_state_list_value" data-optional="1" class="chosen_select en_state_list_value" style="width: 100% !important;" title="States/Provinces"> 561 </select> 562 563 <span class="en_sr_err"></span> 564 </div> 565 </section> 566 </div> 567 448 568 <!-- Available checkbox --> 449 569 <div class="en_sr_form_control"> -
small-package-quotes-ups-edition/trunk/small-package-quotes-ups-edition.php
r3222153 r3237693 4 4 * Plugin URI: https://eniture.com/products/ 5 5 * Description: Dynamically retrieves your negotiated shipping rates from UPS and displays the results in the WooCommerce shopping cart. 6 * Version: 4.5.1 66 * Version: 4.5.17 7 7 * Author: Eniture Technology 8 8 * Author URI: http://eniture.com/ … … 102 102 103 103 // Shipping rules script and styles 104 wp_enqueue_script('en_woo_sr_script', plugin_dir_url(__FILE__) . '/shipping-rules/assets/js/shipping_rules.js', array(), '1.0. 5');105 wp_localize_script('en_woo_sr_script', 's cript', array(104 wp_enqueue_script('en_woo_sr_script', plugin_dir_url(__FILE__) . '/shipping-rules/assets/js/shipping_rules.js', array(), '1.0.6'); 105 wp_localize_script('en_woo_sr_script', 'sr_script', array( 106 106 'pluginsUrl' => plugins_url(), 107 'nonce' => wp_create_nonce('en_woo_sr_nonce') 107 108 )); 108 wp_register_style('shipping_rules_section', plugin_dir_url(__FILE__) . '/shipping-rules/assets/css/shipping_rules.css', false, '1.0. 2');109 wp_register_style('shipping_rules_section', plugin_dir_url(__FILE__) . '/shipping-rules/assets/css/shipping_rules.css', false, '1.0.3'); 109 110 wp_enqueue_style('shipping_rules_section'); 110 111 } … … 186 187 { 187 188 188 wp_register_style('eniture_ups_small_style', plugin_dir_url(__FILE__) . '/css/ups-small-style.css', false, '1.1. 7');189 wp_register_style('eniture_ups_small_style', plugin_dir_url(__FILE__) . '/css/ups-small-style.css', false, '1.1.8'); 189 190 wp_enqueue_style('eniture_ups_small_style'); 190 191 } … … 223 224 { 224 225 wp_enqueue_script('jquery'); 225 wp_enqueue_script('eniture_ups_small_script', plugin_dir_url(__FILE__) . 'js/en-ups-small.js', array(), '1.0. 8');226 wp_enqueue_script('eniture_ups_small_script', plugin_dir_url(__FILE__) . 'js/en-ups-small.js', array(), '1.0.9'); 226 227 wp_localize_script('eniture_ups_small_script', 'eniture_ups_small_admin_script', array( 227 228 'plugins_url' => plugins_url(), … … 229 230 'prevent_proceed_checkout_eniture' => trim(get_option("prevent_proceed_checkout_eniture")), 230 231 'ups_small_order_cutoff_time' => get_option("ups_small_orderCutoffTime"), 231 'ups_small_packaging_type' => get_option("ups_small_packaging_type") 232 'ups_small_packaging_type' => get_option("ups_small_packaging_type"), 233 'nonce' => wp_create_nonce('eniture_ups_small_nonce') 232 234 )); 233 235 } … … 490 492 function eniture_ups_s_fd_api() 491 493 { 494 if (!current_user_can('manage_options') || !wp_verify_nonce($_POST['wp_nonce'], 'eniture_ups_small_nonce')) { 495 echo wp_json_encode([]); 496 return; 497 } 498 492 499 $store_name = eniture_ups_small_get_domain(); 493 500 $company_id = isset($_POST['company_id']) ? sanitize_text_field(wp_unslash($_POST['company_id'])) : ''; … … 499 506 ]; 500 507 if (is_array($data) && count($data) > 0) { 501 if( isset($_POST['disconnect']) && sanitize_text_field(wp_unslash($_POST['disconnect']))!= 'disconnect') {508 if($_POST['disconnect'] != 'disconnect') { 502 509 $url = 'https://freightdesk.online/validate-company'; 503 510 }else { … … 535 542 /** 536 543 * Update FDO coupon data 537 * @param array $request544 * @param array|WP_REST_Request $request 538 545 * @return array|void 539 546 */ 540 547 function eniture_ups_s_fdo_data_status(WP_REST_Request $request) 541 548 { 549 $authenticated_user = fdo_update_status_authenticate($request); 550 if (is_wp_error($authenticated_user)) { 551 return $authenticated_user; 552 } 553 542 554 $status_data = $request->get_body(); 543 555 $status_data_decoded = json_decode($status_data); … … 549 561 } 550 562 563 // fdo / va api calls authentication 564 if (!function_exists('fdo_update_status_authenticate')) { 565 function fdo_update_status_authenticate($request) { 566 if ( !empty( $_SERVER['HTTP_CONSUMER_KEY'] ) && !empty( $_SERVER['HTTP_CONSUMER_SECRET'] ) ) { 567 $consumer_key = $_SERVER['HTTP_CONSUMER_KEY']; 568 $consumer_secret = $_SERVER['HTTP_CONSUMER_SECRET']; 569 }else{ 570 return new WP_Error('rest_authentication_error', __('Invalid Authorization header format.'), array('status' => 401)); 571 } 572 573 global $wpdb; 574 $consumer_key = wc_api_hash( sanitize_text_field( $consumer_key ) ); 575 $user = $wpdb->get_row( 576 $wpdb->prepare( 577 " 578 SELECT user_id, permissions 579 FROM {$wpdb->prefix}woocommerce_api_keys 580 WHERE consumer_key = %s 581 ", 582 $consumer_key 583 ) 584 ); 585 586 if (!$user) { 587 return new WP_Error('invalid_keys', __('Invalid consumer key or secret.'), array('status' => 401)); 588 } 589 590 if (empty($user->permissions) || $user->permissions != 'read_write') { 591 return new WP_Error('rest_forbidden', __('User does not have write permissions.'), array('status' => 403)); 592 } 593 594 return $user; 595 } 596 } 597 551 598 /** 552 599 * Filter to check ground transit status -
small-package-quotes-ups-edition/trunk/template/connection-settings.php
r3147523 r3237693 23 23 $default_api = empty(get_option('ups_small_username')) ? 'ups_new_api' : 'ups_old_api'; 24 24 25 echo '<div class="ups_small_connection_section ">';25 echo '<div class="ups_small_connection_section ups_small_wrapper">'; 26 26 $settings = array( 27 27 'section_title_ups_small' => array( -
small-package-quotes-ups-edition/trunk/template/csv-export.php
r3147523 r3237693 5 5 } 6 6 7 if (!class_exists('En iture_CsvExport')) {8 9 class En iture_CsvExport7 if (!class_exists('EnCsvExport')) { 8 9 class EnCsvExport 10 10 { 11 11 public function __construct() … … 50 50 if (isset($columns['meta:_ltl_freight_variation'])) { 51 51 unset($columns['meta:_ltl_freight_variation']); 52 } 53 54 $nested_mat_cols = ['_nestedmaterials', '_nestedpercentage', '_nesteddimension', '_maxnesteditems', '_nestedstakingproperty']; 55 foreach ($nested_mat_cols as $nested_mat_col) { 56 if (isset($columns['meta:' . $nested_mat_col])) { 57 unset($columns['meta:' . $nested_mat_col]); 58 } 59 60 if (isset($columns['Meta:' . $nested_mat_col])) { 61 unset($columns['Meta:' . $nested_mat_col]); 62 } 52 63 } 53 64 … … 261 272 } 262 273 263 new En iture_CsvExport();274 new EnCsvExport(); 264 275 } -
small-package-quotes-ups-edition/trunk/template/guide.php
r1785132 r3237693 14 14 */ 15 15 ?> 16 <div class="user_guide ">16 <div class="user_guide ups_small_wrapper"> 17 17 <p> 18 18 The User Guide for this application is maintained on the publisher's website. To view it click -
small-package-quotes-ups-edition/trunk/template/products-nested-options.php
r3147523 r3237693 7 7 exit; 8 8 } 9 if (!class_exists("En iture_UpdateProductNestedOptions")) {10 11 class En iture_UpdateProductNestedOptions9 if (!class_exists("EnUpdateProductNestedOptions")) { 10 11 class EnUpdateProductNestedOptions 12 12 { 13 13 … … 221 221 222 222 /* Initialize object */ 223 new En iture_UpdateProductNestedOptions('hooks');223 new EnUpdateProductNestedOptions('hooks'); 224 224 } -
small-package-quotes-ups-edition/trunk/template/quote-settings.php
r3159756 r3237693 85 85 //**End: Cut Off Time & Ship Date Offset 86 86 87 echo '<div class="ups_small_quote_section ">';87 echo '<div class="ups_small_quote_section ups_small_wrapper">'; 88 88 89 89 $settings = array( -
small-package-quotes-ups-edition/trunk/update-plan.php
r3147523 r3237693 16 16 function eniture_ups_small_activate_hit_to_update_plan($network_wide = null) 17 17 { 18 if (!current_user_can('manage_options')) { 19 echo json_encode([]); 20 return; 21 } 22 18 23 if ( is_multisite() && $network_wide ) { 19 24 … … 244 249 245 250 if (isset($plan_package['plan_number']) && $plan_package['plan_number'] == '0') { 246 echo '<div class="notice notice-success is-dismissible ">251 echo '<div class="notice notice-success is-dismissible ups_small_plan_notice"> 247 252 <p> You are currently on the ' . esc_attr( $plan_package['plan_name'] ) . '. Your plan will be expire on ' . esc_attr( $plan_package['expiry_date'] ) . ' <a href="javascript:void(0)" data-action="eniture_ups_small_activate_hit_to_update_plan" onclick="en_update_plan(this);">Click here</a> to refresh the plan.</p> 248 253 </div>'; 249 254 } else if (isset($plan_package['plan_number']) && ($plan_package['plan_number'] == '1' || $plan_package['plan_number'] == '2' || $plan_package['plan_number'] == '3')) { 250 255 251 echo '<div class="notice notice-success is-dismissible ">256 echo '<div class="notice notice-success is-dismissible ups_small_plan_notice"> 252 257 <p> You are currently on the ' . esc_attr( $plan_package['plan_name'] ) . '. The plan renews on ' . esc_attr( $plan_package['expiry_date'] ) . ' <a href="javascript:void(0)" data-action="eniture_ups_small_activate_hit_to_update_plan" onclick="en_update_plan(this);">Click here</a> to refresh the plan.</p> 253 258 </div>'; 254 259 } else { 255 echo '<div class="notice notice-warning is-dismissible ">260 echo '<div class="notice notice-warning is-dismissible ups_small_plan_notice"> 256 261 <p>Your currently plan subscription is inactive. <a href="javascript:void(0)" data-action="eniture_ups_small_activate_hit_to_update_plan" onclick="en_update_plan(this);">Click here</a> to refresh the plan to check the subscription status. If the subscription status remains inactive, log into eniture.com and update your license.</p> 257 262 </div>'; -
small-package-quotes-ups-edition/trunk/ups-small-admin-filter.php
r3206249 r3237693 173 173 $metaValue[3] = $locations[3][$key]; 174 174 $metaValue[4] = $locations[4][$key]; 175 $dsId[] = en iture_serialize_dropship($metaValue);175 $dsId[] = en_serialize_dropship($metaValue); 176 176 } 177 177 } 178 178 } else { 179 $dsId[] = en iture_serialize_dropship($_dropship_location);179 $dsId[] = en_serialize_dropship($_dropship_location); 180 180 } 181 181 … … 199 199 */ 200 200 201 if (!function_exists('en iture_serialize_dropship')) {202 function en iture_serialize_dropship($metaValue)201 if (!function_exists('en_serialize_dropship')) { 202 function en_serialize_dropship($metaValue) 203 203 { 204 204 global $wpdb; … … 215 215 216 216 if (empty($dropship['id'])) { 217 $data = en iture_csv_import_dropship_data($metaValue);217 $data = en_csv_import_dropship_data($metaValue); 218 218 $wpdb->insert( 219 219 $wpdb->prefix . 'warehouse', $data … … 234 234 * @return array 235 235 */ 236 if (!function_exists('en iture_csv_import_dropship_data')) {237 function en iture_csv_import_dropship_data($metaValue)236 if (!function_exists('en_csv_import_dropship_data')) { 237 function en_csv_import_dropship_data($metaValue) 238 238 { 239 239 return array( -
small-package-quotes-ups-edition/trunk/ups-small-carrier-service.php
r3219695 r3237693 479 479 $response_json = $ups_Small_distance_request->ups_small_address($warehous_list, $accessLevel, $this->destinationAddressUpsSmall()); 480 480 $response_json = json_decode($response_json, TRUE); 481 482 // Eniture debug mood 483 do_action("eniture_debug_mood", "Multi Warehouse Distance Response (UPS Small)", $response_json); 484 481 485 return $response_json['origin_with_min_dist']; 482 486 } -
small-package-quotes-ups-edition/trunk/ups-small-group-package.php
r3219695 r3237693 27 27 public $destination_Address_ups_small; 28 28 public $origin = []; 29 public $shipping_rule_object; 29 30 // Images for FDO 30 31 public $en_fdo_image_urls = []; … … 156 157 $width = (strlen($width) > 0) ? $width : "0"; 157 158 $length = (strlen($length) > 0) ? $length : "0"; 158 159 159 160 $product_weight = apply_filters('en_filter_product_weight', wc_get_weight($_product->get_weight(), 'lbs'), $item_id); 160 161 … … 174 175 } 175 176 } 176 177 177 178 $product_level_markup = $this->ups_small_get_product_level_markup($_product, $values['variation_id'], $product_id, $values['quantity']); 178 179 … … 468 469 if ($freight_enable_class == 'ltl_freight' || $freight_enable_class == 'ltl-freight') { 469 470 $ptype = 'ltl'; 470 } else if ($exceedWeight == 'yes' 471 } else if ($exceedWeight == 'yes' 471 472 && ( ($weight > $weight_threshold && $en_multiple_package != 'yes') || (!empty($only_show_ltl_rates) && $only_show_ltl_rates == 'yes' && $shipment_weight_sum > $weight_threshold) )) { 472 473 $ptype = 'ltl'; … … 475 476 } 476 477 478 // Eniture debug mode 479 do_action("eniture_debug_mood", "Quotes Product Type (UPS Small)", $ptype); 480 477 481 return $ptype; 478 482 } … … 481 485 * Hazardous Material in Product Detail page 482 486 * @param array $values 483 * @param array $_product487 * @param array|object $_product 484 488 * @return string 485 489 */ … … 493 497 * 494 498 * @param array $values 495 * @param array $_product499 * @param array|object $_product 496 500 * @return string 497 501 */ … … 520 524 // Micro Warehouse 521 525 $this->warehouse_products[] = $post_id; 522 return array('error' => 'wwe small dp location not found!'); 526 527 // Eniture debug mode 528 do_action("eniture_debug_mood", "Quotes Dropship Location (UPS Small)", array('error' => 'UPS Small dropship location not found!')); 529 530 return array('error' => 'UPS Small dropship location not found!'); 523 531 } 524 532 … … 536 544 "SELECT * FROM " . $wpdb->prefix . "warehouse WHERE id IN ('" . $get_loc . "')" 537 545 ); 546 } 547 548 if (empty($locations_list)) { 549 // Eniture debug mode 550 do_action("eniture_debug_mood", "Quotes Dropship Location (UPS Small)", array('error' => 'UPS Small dropship location not found!')); 538 551 } 539 552 … … 658 671 { 659 672 $product_level_markup = 0; 660 673 661 674 if ($_product->get_type() == 'variation') { 662 675 $product_level_markup = get_post_meta($variation_id, '_en_product_markup_variation', true); … … 667 680 $product_level_markup = get_post_meta($_product->get_id(), '_en_product_markup', true); 668 681 } 669 682 670 683 if (empty($product_level_markup)) { 671 684 $product_level_markup = get_post_meta($product_id, '_en_product_markup', true); 672 685 } 673 686 674 if (!empty($product_level_markup) && strpos($product_level_markup, '%') === false 687 if (!empty($product_level_markup) && strpos($product_level_markup, '%') === false 675 688 && is_numeric($product_level_markup) && is_numeric($quantity)) 676 689 { … … 682 695 $percentage_value = $arr[0]; 683 696 $product_price = $_product->get_price(); 684 697 685 698 if (!empty($product_price)) { 686 699 $product_level_markup = $percentage_value / 100 * ($product_price * $quantity); … … 689 702 } 690 703 } 691 704 692 705 return $product_level_markup; 693 706 } … … 696 709 * Check except transit time restriction 697 710 * @param array $values 698 * @param array $_product711 * @param array|object $_product 699 712 * @return string 700 713 */ … … 730 743 731 744 if (empty($rules)) return $apply_on_rates ? $rates : false; 732 745 733 746 $is_rule_applied = false; 734 $rule_types = ['override_rates' => 'Override Rates', 'hide_methods' => 'Hide Methods', 'restrict_to_state' => 'Restrict To State', 'hide_methods_by_origin' => 'Hide Methods By Origin' ];747 $rule_types = ['override_rates' => 'Override Rates', 'hide_methods' => 'Hide Methods', 'restrict_to_state' => 'Restrict To State', 'hide_methods_by_origin' => 'Hide Methods By Origin', 'minimum_shipping_charge' => 'Minimum Shipping Charge']; 735 748 736 749 foreach ($rules as $rule) { … … 741 754 742 755 $rule_type = isset($rule['type']) ? $rule['type'] : ''; 756 $rule_name = isset($rule['name']) ? $rule['name'] : ''; 743 757 744 758 if ($rule_type == $rule_types['override_rates'] && $apply_on_rates) { 745 $rates = $this->apply_override_rates_rule($ups_small_package, $settings, $rates );759 $rates = $this->apply_override_rates_rule($ups_small_package, $settings, $rates, $rule_name); 746 760 } else if ($rule_type == $rule_types['hide_methods']) { 747 761 $is_rule_applied = $this->apply_rule($settings, $ups_small_package); … … 749 763 } else if ($rule_type == $rule_types['restrict_to_state'] && $apply_on_rates) { 750 764 $rates = $this->apply_restrict_to_state_rule($ups_small_package, $settings, $rates); 765 766 // Eniture debug mode 767 do_action("eniture_debug_mood", "UPS Small Restrict To State Rule Updated Rates: {$rule_name}", wp_json_encode($rates)); 751 768 } else if ($rule_type == $rule_types['hide_methods_by_origin'] && $apply_on_rates) { 752 769 $rates = $this->apply_hide_methods_by_origin_rule($settings, $rates); 770 } else if ($rule_type == $rule_types['minimum_shipping_charge'] && $apply_on_rates) { 771 $rates = $this->apply_minimum_shipping_charge_rule($ups_small_package, $settings, $rates, $rule_name); 753 772 } 754 773 } … … 777 796 } 778 797 798 // Eniture debug mode 799 do_action("eniture_debug_mood", "UPS Small Hide Methods Rule Applied", $is_rule_applied ? 'Yes' : 'No'); 800 779 801 return $is_rule_applied; 780 802 } … … 794 816 } 795 817 796 function apply_rule_filters($settings, $formatted_values, $restict_service = false )818 function apply_rule_filters($settings, $formatted_values, $restict_service = false, $override_rates = false) 797 819 { 798 820 $is_filter_applied = false; 799 821 $filters = ['weight', 'price', 'quantity']; 800 822 // Add restrict service filters in case of restrict to state rule 801 $filters = $restict_service? array_merge(['country'], $filters) : $filters;823 $filters = ($restict_service || $override_rates) ? array_merge(['country'], $filters) : $filters; 802 824 803 825 // Check if any of the filter is checked 804 $filters_checks = ['filter_by_weight', 'filter_by_price', 'filter_by_quantity', 'filter_by_product_tag', 'filter_by_country', 'filter_by_state' ];826 $filters_checks = ['filter_by_weight', 'filter_by_price', 'filter_by_quantity', 'filter_by_product_tag', 'filter_by_country', 'filter_by_state', 'filter_by_country_or', 'filter_by_state_or']; 805 827 $any_filter_checked = false; 806 828 foreach ($filters_checks as $check) { … … 819 841 820 842 foreach ($filters as $filter) { 821 if (filter_var($settings['filter_by_' . $filter], FILTER_VALIDATE_BOOLEAN)) { 843 $override_rate_filter = isset($settings['filter_by_' . $filter . '_or']) ? filter_var($settings['filter_by_' . $filter . '_or'], FILTER_VALIDATE_BOOLEAN) : false; 844 845 if (filter_var($settings['filter_by_' . $filter], FILTER_VALIDATE_BOOLEAN) || $override_rate_filter) { 822 846 if ($filter == 'country') { 823 847 $destination_country = isset($destination_address['country']) ? $destination_address['country'] : ''; 824 $this->is_dest_country_matched = $this->is_country_matched($settings['filter_by_country_value'],$destination_country); 848 $filter_by_country = $override_rate_filter ? 'filter_by_country_value_or' : 'filter_by_country_value'; 849 $this->is_dest_country_matched = $this->is_country_matched($settings[$filter_by_country], $destination_country); 825 850 $is_filter_applied = $this->is_dest_country_matched; 826 851 $this->is_country_filter_applied = true; 827 852 828 if ($is_filter_applied && filter_var($settings['filter_by_state'], FILTER_VALIDATE_BOOLEAN)) { 853 $filter_by_state = $override_rate_filter ? 'filter_by_state_or' : 'filter_by_state'; 854 $filter_by_state_value = $override_rate_filter ? 'filter_by_state_value_or' : 'filter_by_state_value'; 855 856 if ($is_filter_applied && filter_var($settings[$filter_by_state], FILTER_VALIDATE_BOOLEAN)) { 829 857 $destination_state = isset($destination_address['state']) ? $destination_address['state'] : ''; 830 $states = isset($settings[ 'filter_by_state_value']) ? $settings['filter_by_state_value'] : [];858 $states = isset($settings[$filter_by_state_value]) ? $settings[$filter_by_state_value] : []; 831 859 $is_filter_applied = $this->is_dest_country_matched = in_array($destination_state, $states); 832 860 } … … 853 881 } 854 882 855 function apply_override_rates_rule($ups_small_package, $settings, $rates )883 function apply_override_rates_rule($ups_small_package, $settings, $rates, $rule_name) 856 884 { 857 885 $updated_rates = $rates; … … 859 887 foreach ($ups_small_package as $org_zip => $pkg) { 860 888 $is_rule_applied = false; 889 $this->is_country_filter_applied = false; 890 $this->is_dest_country_matched = false; 861 891 $shipments = []; 862 892 $org_zip = isset($pkg['zip']) ? $pkg['zip'] : $org_zip; … … 864 894 865 895 $formatted_values = $this->get_formatted_values($shipments); 866 $is_rule_applied = $this->apply_rule_filters($settings, $formatted_values );896 $is_rule_applied = $this->apply_rule_filters($settings, $formatted_values, false, true); 867 897 868 898 if ($is_rule_applied) { 869 $updated_rates = $this->get_updated_rates($updated_rates, $settings, false, $org_zip );899 $updated_rates = $this->get_updated_rates($updated_rates, $settings, false, $org_zip, false); 870 900 }; 871 901 } 872 902 903 // Eniture debug mode 904 $data = ['rule_name' => $rule_name, 'settings' => $settings, 'rates' => json_encode($rates), 'updated_rates' => json_encode($updated_rates)]; 905 do_action("eniture_debug_mood", "UPS Small Override Rates Rule Applied: {$rule_name}", $data); 906 873 907 return $updated_rates; 874 908 } 875 909 876 function apply_restrict_to_state_rule($ups_small_package, $settings, $rates) 877 { 910 function apply_restrict_to_state_rule($ups_small_package, $settings, $rates) 911 { 912 $this->is_country_filter_applied = false; 913 $this->is_dest_country_matched = false; 914 878 915 $formatted_values = $this->get_formatted_values($ups_small_package); 879 916 $is_rule_applied = $this->apply_rule_filters($settings, $formatted_values, true); 880 917 $this->is_restrict_service_rule_applied = $is_rule_applied; 881 918 882 return ($is_rule_applied || ($this->is_country_filter_applied && !$this->is_dest_country_matched)) ? $this->get_updated_rates($rates, $settings, true) : $rates; 883 } 884 885 function get_updated_rates($rates, $settings, $restict_service = false, $org_zip = '') 919 // Eniture debug mode 920 do_action("eniture_debug_mood", "UPS Small Restrict To State Rule Applied", $is_rule_applied ? 'Yes' : 'No'); 921 922 return ($is_rule_applied || ($this->is_country_filter_applied && !$this->is_dest_country_matched)) ? $this->get_updated_rates($rates, $settings, true, '', false) : $rates; 923 } 924 925 function get_updated_rates($rates, $settings, $restict_service = false, $org_zip = '', $min_shipping_charge = false) 886 926 { 887 927 if ($restict_service) { 888 928 if ($this->is_country_filter_applied && !$this->is_dest_country_matched) { 889 929 $rates_keys = ['q', 'ups_rate', 'GFP', 'q_92', 'q_93', 'q_94', 'q_95', 'usrg', 'usr2', 'usr1', 'usr3']; 890 930 891 931 foreach ($rates as $key => $value) { 892 932 foreach ($rates_keys as $rates_key) { … … 896 936 } 897 937 } else { 938 $this->shipping_rule_object = new Eniture_UpsSmallShippingRulesAjaxReq(); 939 898 940 foreach ($rates as $key => $result) { 899 if ($key != $org_zip ) continue;941 if ($key != $org_zip && !empty($org_zip)) continue; 900 942 901 943 $ups_quotes = (isset($result->q) && !empty($result->q)) ? $result->q : []; … … 904 946 $rates_key = isset($result->ups_rate) ? 'ups_rate' : $rates_key; 905 947 $simple_rate_services = ['usrg', 'usr2', 'usr1', 'usr3']; 906 948 907 949 if (empty($ups_quotes)) continue; 908 950 909 951 foreach ($ups_quotes as $service_key => $val) { 910 952 $rate_arr = $this->get_rate_arr($val); 911 953 $service_code = isset($settings['service']) ? $settings['service'] : ''; 912 954 955 // minimum shipping charge settings 956 $msc_service_exists = false; 957 if ($min_shipping_charge) { 958 $services_codes = isset($settings['minimum_shipping_charge_services']) ? $settings['minimum_shipping_charge_services'] : []; 959 $msc_service_exists = in_array($rate_arr->Service->Code, $services_codes) || in_array($service_key, $services_codes); 960 } 961 913 962 // Replace service rate with new rate defined in the shipping rule 914 if (isset($rate_arr->Service->Code) && $rate_arr->Service->Code == $service_code&& $rates_key != '') {963 if (isset($rate_arr->Service->Code) && ($rate_arr->Service->Code == $service_code || $msc_service_exists) && $rates_key != '') { 915 964 if ($service_key == 'GFP') { 916 965 // Legacy API response 917 966 if (isset($val->soapenvBody->rateRateResponse->rateRatedShipment->rateTotalCharges->rateMonetaryValue)) { 918 $rates[$key]->$rates_key->$service_key->soapenvBody->rateRateResponse->rateRatedShipment->rateTotalCharges->rateMonetaryValue = $settings['service_rate']; 967 $net_rate = $val->soapenvBody->rateRateResponse->rateRatedShipment->rateTotalCharges->rateMonetaryValue; 968 $rates[$key]->$rates_key->$service_key->soapenvBody->rateRateResponse->rateRatedShipment->rateTotalCharges->rateMonetaryValue = $this->shipping_rule_object->ups_small_get_service_rate($net_rate, $settings, $msc_service_exists); 919 969 } 920 970 921 971 // New API response 922 972 if (isset($val->RateResponse->RatedShipment->TotalCharges->MonetaryValue)) { 923 $rates[$key]->$rates_key->$service_key->RateResponse->RatedShipment->TotalCharges->MonetaryValue = $settings['service_rate']; 973 $net_rate = $val->RateResponse->RatedShipment->TotalCharges->MonetaryValue; 974 $rates[$key]->$rates_key->$service_key->RateResponse->RatedShipment->TotalCharges->MonetaryValue = $this->shipping_rule_object->ups_small_get_service_rate($net_rate, $settings, $msc_service_exists); 924 975 } 925 976 926 977 $rates[$key]->$rates_key->$service_key->overrideRate = true; 927 978 } else { 928 979 if (isset($rate_arr->TotalCharges->MonetaryValue)) { 929 980 if (isset($rates[$key]->$rates_key->$service_key->TotalCharges->MonetaryValue)) { 930 $rates[$key]->$rates_key->$service_key->TotalCharges->MonetaryValue = $settings['service_rate']; 981 $net_rate = $rates[$key]->$rates_key->$service_key->TotalCharges->MonetaryValue; 982 $rates[$key]->$rates_key->$service_key->TotalCharges->MonetaryValue = $this->shipping_rule_object->ups_small_get_service_rate($net_rate, $settings, $msc_service_exists); 931 983 } 932 984 933 985 if (isset($rates[$key]->$rates_key->$service_key->RatedShipment->TotalCharges->MonetaryValue)) { 934 $rates[$key]->$rates_key->$service_key->RatedShipment->TotalCharges->MonetaryValue = $settings['service_rate']; 986 $net_rate = $rates[$key]->$rates_key->$service_key->RatedShipment->TotalCharges->MonetaryValue; 987 $rates[$key]->$rates_key->$service_key->RatedShipment->TotalCharges->MonetaryValue = $this->shipping_rule_object->ups_small_get_service_rate($net_rate, $settings, $msc_service_exists); 935 988 } 936 989 } 937 990 938 991 if (isset($rate_arr->NegotiatedRateCharges->TotalCharge->MonetaryValue)) { 939 992 if (isset($rates[$key]->$rates_key->$service_key->NegotiatedRateCharges->TotalCharge->MonetaryValue)) { 940 $rates[$key]->$rates_key->$service_key->NegotiatedRateCharges->TotalCharge->MonetaryValue = $settings['service_rate']; 993 $net_rate = $rates[$key]->$rates_key->$service_key->NegotiatedRateCharges->TotalCharge->MonetaryValue; 994 $rates[$key]->$rates_key->$service_key->NegotiatedRateCharges->TotalCharge->MonetaryValue = $this->shipping_rule_object->ups_small_get_service_rate($net_rate, $settings, $msc_service_exists); 941 995 } 942 996 943 997 if (isset($rates[$key]->$rates_key->$service_key->RatedShipment->NegotiatedRateCharges->TotalCharge->MonetaryValue)) { 944 $rates[$key]->$rates_key->$service_key->RatedShipment->NegotiatedRateCharges->TotalCharge->MonetaryValue = $settings['service_rate']; 998 $net_rate = $rates[$key]->$rates_key->$service_key->RatedShipment->NegotiatedRateCharges->TotalCharge->MonetaryValue; 999 $rates[$key]->$rates_key->$service_key->RatedShipment->NegotiatedRateCharges->TotalCharge->MonetaryValue = $this->shipping_rule_object->ups_small_get_service_rate($net_rate, $settings, $msc_service_exists); 945 1000 } 946 1001 } 947 1002 948 1003 if (isset($rate_arr->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue)) { 949 1004 if (isset($rates[$key]->$rates_key->$service_key->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue)) { 950 $rates[$key]->$rates_key->$service_key->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue = $settings['service_rate']; 1005 $net_rate = $rates[$key]->$rates_key->$service_key->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue; 1006 $rates[$key]->$rates_key->$service_key->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue = $this->shipping_rule_object->ups_small_get_service_rate($net_rate, $settings, $msc_service_exists); 951 1007 } 952 1008 953 1009 if (isset($rates[$key]->$rates_key->$service_key->RatedShipment->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue)) { 954 $rates[$key]->$rates_key->$service_key->RatedShipment->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue = $settings['service_rate']; 1010 $net_rate = $rates[$key]->$rates_key->$service_key->RatedShipment->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue; 1011 $rates[$key]->$rates_key->$service_key->RatedShipment->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue = $this->shipping_rule_object->ups_small_get_service_rate($net_rate, $settings, $msc_service_exists); 955 1012 } 956 1013 } 957 1014 958 1015 $rates[$key]->$rates_key->$service_key->overrideRate = true; 959 1016 } 960 1017 } 961 1018 962 1019 // UPS simple rate services 963 if (in_array($service_key, $simple_rate_services) && $service_key == $service_code&& $rates_key != '' && isset($val->rate)) {1020 if (in_array($service_key, $simple_rate_services) && ($service_key == $service_code || $msc_service_exists) && $rates_key != '' && isset($val->rate)) { 964 1021 if ($rates[$key]->$rates_key->$service_key->rate) { 965 $rates[$key]->$rates_key->$service_key->rate = $settings['service_rate']; 1022 $net_rate = $rates[$key]->$rates_key->$service_key->rate; 1023 $rates[$key]->$rates_key->$service_key->rate = $this->shipping_rule_object->ups_small_get_service_rate($net_rate, $settings, $msc_service_exists); 966 1024 $rates[$key]->$rates_key->$service_key->overrideRate = true; 967 1025 } … … 974 1032 } 975 1033 976 function is_country_matched($selected_country, $destination_country) 1034 function is_country_matched($selected_country, $destination_country) 977 1035 { 978 1036 $is_matched = false; … … 1021 1079 } 1022 1080 } 1081 1082 // Eniture debug mode 1083 $data = ['settings' => $settings, 'rates' => json_encode($rates), 'updated_rates' => json_encode($updated_rates)]; 1084 do_action("eniture_debug_mood", "UPS Small Hide Methods By Origin Rule Applied", $data); 1023 1085 1024 1086 return $updated_rates; … … 1047 1109 return $rate_arr; 1048 1110 } 1111 1112 function apply_minimum_shipping_charge_rule($ups_small_package, $settings, $rates, $rule_name) 1113 { 1114 $is_rule_applied = false; 1115 $updated_rates = $rates; 1116 1117 if ($settings['apply_to'] == 'cart') { 1118 $formatted_values = $this->get_formatted_values($ups_small_package); 1119 $is_rule_applied = $this->apply_rule_filters($settings, $formatted_values); 1120 1121 if ($is_rule_applied) { 1122 $updated_rates = $this->get_updated_rates($updated_rates, $settings, false, '', true); 1123 } 1124 } else { 1125 foreach ($ups_small_package as $org_zip => $pkg) { 1126 $is_rule_applied = false; 1127 $shipments = []; 1128 $org_zip = isset($pkg['zip']) ? $pkg['zip'] : $org_zip; 1129 $shipments[$org_zip] = $pkg; 1130 1131 $formatted_values = $this->get_formatted_values($shipments); 1132 $is_rule_applied = $this->apply_rule_filters($settings, $formatted_values); 1133 1134 if ($is_rule_applied) { 1135 $updated_rates = $this->get_updated_rates($updated_rates, $settings, false, $org_zip, true); 1136 } 1137 } 1138 } 1139 1140 // Eniture debug mode 1141 $data = ['rule_name' => $rule_name, 'settings' => $settings, 'rates' => json_encode($rates), 'updated_rates' => json_encode($updated_rates)]; 1142 do_action("eniture_debug_mood", "UPS Small Minimum Shipping Charge Rule Applied", $data); 1143 1144 return $updated_rates; 1145 } 1049 1146 } -
small-package-quotes-ups-edition/trunk/ups-small-shipping-class.php
r3198871 r3237693 261 261 ); 262 262 $this->add_rate($rates); 263 263 264 // Eniture debug mode 265 do_action("eniture_debug_mood", "Free Shipping (-100% Handling Fee) Applied (UPS Small)", $rates); 266 264 267 return []; 265 268 } 266 269 267 270 $ups_small_package = $get_packg_obj->group_ups_small_shipment($package, $ups_small_res_inst, $freight_zipcode); 271 272 // Apply free shipping rule 273 $free_shipping_rate = (new Eniture_UpsSmallShippingRulesAjaxReq())->apply_free_shipping_rule($ups_small_package); 274 if (isset($free_shipping_rate['rates']) && !empty($free_shipping_rate['rates']) && is_array($free_shipping_rate['rates'])) { 275 $this->add_rate($free_shipping_rate['rates']); 276 return []; 277 } 278 279 $ups_small_package = isset($free_shipping_rate['package']) ? $free_shipping_rate['package'] : $ups_small_package; 280 268 281 // Apply hide methods shipping rules 269 282 $shipping_rules_applied = $get_packg_obj->apply_shipping_rules($ups_small_package); … … 290 303 $ups_small_package[$org_id]['is_shipment'] = 'ltl'; 291 304 $ups_small_package[$org_id]['origin']['ptype'] = 'ltl'; 305 306 // Eniture debug mode 307 do_action("eniture_debug_mood", "Suppressing UPS Small Package Rates (Weight Threshold)", $ups_small_package[$org_id]); 292 308 } 293 309 } … … 352 368 $en_is_shipment = (count($quotes) > 1) || !empty($virtual_rate) ? 'en_multi_shipment' : 'en_single_shipment'; 353 369 370 // Eniture debug mode 371 do_action("eniture_debug_mood", "Shipment Type (UPS Small)", $en_is_shipment); 372 354 373 $this->quote_settings['shipment'] = $en_is_shipment; 355 374 $this->eniture_rates = []; … … 380 399 } 381 400 } 401 382 402 if ($this->en_not_returned_the_quotes) { 403 // Eniture debug mode 404 do_action("eniture_debug_mood", "UPS Small Quotes not returned", $this->en_not_returned_the_quotes ? 'Yes' : 'No'); 405 383 406 return []; 384 407 } 408 385 409 if ($en_is_shipment == 'en_single_shipment') { 386 410 // In-store pickup and local delivery -
small-package-quotes-ups-edition/trunk/ups-small-test-connection.php
r3147523 r3237693 19 19 function eniture_ups_test_submit() 20 20 { 21 if (!current_user_can('manage_options') || !wp_verify_nonce($_POST['wp_nonce'], 'eniture_ups_small_nonce')) { 22 echo json_encode([]); 23 exit; 24 } 25 21 26 $iAcountNumber = (isset($_POST['ups_small_acc_number'])) ? sanitize_text_field(wp_unslash( $_POST['ups_small_acc_number'] )) : ''; 22 27 $sLicenseKey = (isset($_POST['ups_small_license'])) ? sanitize_text_field(wp_unslash( $_POST['ups_small_license'] )) : ''; -
small-package-quotes-ups-edition/trunk/warehouse-dropship/get-distance-request.php
r3147523 r3237693 41 41 ); 42 42 43 // Eniture debug mode 44 do_action("eniture_debug_mood", "Multi Warehouse Distance Request (UPS Small)", $postData); 43 45 44 46 $Ups_Small_Curl_Request = new Eniture_UPS_Small_Curl_Request(); -
small-package-quotes-ups-edition/trunk/warehouse-dropship/wild-delivery.php
r3148641 r3237693 20 20 )); 21 21 22 wp_enqueue_script('en_woo_wd_script', plugin_dir_url(__FILE__) . '/wild/assets/js/warehouse_section.js', array(), '1.0. 5');22 wp_enqueue_script('en_woo_wd_script', plugin_dir_url(__FILE__) . '/wild/assets/js/warehouse_section.js', array(), '1.0.6'); 23 23 wp_localize_script('en_woo_wd_script', 'script', array( 24 24 'pluginsUrl' => plugins_url(), … … 27 27 wp_register_style('warehouse_section', plugin_dir_url(__FILE__) . '/wild/assets/css/warehouse_section.css', false, '1.0.4'); 28 28 wp_enqueue_style('warehouse_section'); 29 wp_localize_script('en_woo_wd_script', 'en_ups_small_wh_script', array( 30 'pluginsUrl' => plugins_url(), 31 'nonce' => wp_create_nonce("en_woo_wd_nonce"), 32 )); 29 33 } 30 34 … … 69 73 class="en_wd_add_warehouse_btn <?php echo esc_attr($multi_warehouse_disabled); 70 74 ?>" name="avc">Add</a> 75 76 <?php 77 echo "<br /> <br />"; 78 // Eniture debug mode 79 do_action("eniture_debug_mood", "UPS Small Warehouse List", $warehous_list); 80 ?> 71 81 72 82 <div class="wild_warehouse pakage_notify heading_right"> … … 132 142 <td class="en_wd_warehouse_list_data"> 133 143 <a href="javascript(0)" 134 onclick="return en iture_wd_edit_warehouse(<?php echo (isset($list->id)) ? esc_attr($list->id) : ''; ?>);"><img144 onclick="return en_ups_small_wd_edit_warehouse(<?php echo (isset($list->id)) ? esc_attr($list->id) : ''; ?>);"><img 135 145 src="<?php echo esc_url_raw(plugins_url()); ?>/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/edit.png" 136 146 title="Edit"></a> 137 147 <a href="javascript(0)" 138 onclick="return en_ wd_delete_current_warehouse(<?php echo (isset($list->id)) ? esc_attr($list->id) : ''; ?>);"><img148 onclick="return en_ups_small_wd_delete_current_warehouse(<?php echo (isset($list->id)) ? esc_attr($list->id) : ''; ?>);"><img 139 149 src="<?php echo esc_url_raw(plugins_url()); ?>/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/delete.png" 140 150 title="Delete"></a> … … 196 206 class="en_wd_add_dropship_btn hide_drop_val <?php echo esc_attr($multi_dropship_disabled); ?>">Add</a> 197 207 208 <?php 209 echo "<br /> <br />"; 210 // Eniture debug mode 211 do_action("eniture_debug_mood", "UPS Small Dropship List", $dropship_list); 212 ?> 213 198 214 <div class="wild_warehouse pakage_notify heading_right"> 199 215 <?php echo $multi_dropship_package_required; ?> … … 264 280 <td class="en_wd_dropship_list_data"> 265 281 <a href="javascript(0)" 266 onclick="return en iture_wd_edit_dropship(<?php echo (isset($list->id)) ? esc_attr($list->id) : ''; ?>);"><img282 onclick="return en_ups_small_wd_edit_dropship(<?php echo (isset($list->id)) ? esc_attr($list->id) : ''; ?>);"><img 267 283 src="<?php echo esc_url_raw(plugins_url()); ?>/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/edit.png" 268 284 title="Edit"></a> 269 285 <a href="javascript(0)" 270 onclick="return en_ wd_delete_current_dropship(<?php echo (isset($list->id)) ? esc_attr($list->id) : ''; ?>);"><img286 onclick="return en_ups_small_wd_delete_current_dropship(<?php echo (isset($list->id)) ? esc_attr($list->id) : ''; ?>);"><img 271 287 src="<?php echo esc_url_raw(plugins_url()); ?>/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/delete.png" 272 288 title="Delete"></a> -
small-package-quotes-ups-edition/trunk/warehouse-dropship/wild/assets/js/warehouse_section.js
r3148641 r3237693 322 322 * @returns {Boolean} 323 323 */ 324 if (typeof en_ wd_save_warehouse != 'function')325 { 326 function en_ wd_save_warehouse()324 if (typeof en_ups_small_wd_save_warehouse != 'function') 325 { 326 function en_ups_small_wd_save_warehouse() 327 327 { 328 328 var validate = enWdValidateInput("#add_warehouses"); … … 342 342 343 343 var postForm = { 344 'action': 'en iture_wd_save_warehouse',344 'action': 'en_ups_small_wd_save_warehouse', 345 345 'origin_id': jQuery('#edit_form_id').val(), 346 346 'origin_city': city, … … 355 355 // preferred origin 356 356 'pref_loc_lfq': jQuery('#add_warehouses #pref_loc_lfq').val(), 357 'pref_loc_spq': jQuery('#add_warehouses #pref_loc_spq').val() 357 'pref_loc_spq': jQuery('#add_warehouses #pref_loc_spq').val(), 358 'wp_nonce': en_ups_small_wh_script.nonce 358 359 }; 359 360 … … 389 390 } else if (data.update_qry == 1) { 390 391 391 jQuery('tr[id=row_' + WarehpuseDataId + ']').html('<td class="en_wd_warehouse_list_data">' + data.origin_city + '</td><td class="en_wd_warehouse_list_data">' + data.origin_state + '</td><td class="en_wd_warehouse_list_data">' + data.origin_zip + '</td><td class="en_wd_warehouse_list_data">' + data.origin_country + '</td><td class="en_wd_warehouse_list_data"><a href="javascript(0)" title="Edit" onclick="return en iture_wd_edit_warehouse(' + WarehpuseDataId + ')"><img src="' + script.pluginsUrl + '/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/edit.png"></a><a href="javascript(0)" title="Delete" onclick="return en_wd_delete_current_warehouse(' + WarehpuseDataId + ');"><img src="' + script.pluginsUrl + '/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/delete.png"></a></td>');392 jQuery('tr[id=row_' + WarehpuseDataId + ']').html('<td class="en_wd_warehouse_list_data">' + data.origin_city + '</td><td class="en_wd_warehouse_list_data">' + data.origin_state + '</td><td class="en_wd_warehouse_list_data">' + data.origin_zip + '</td><td class="en_wd_warehouse_list_data">' + data.origin_country + '</td><td class="en_wd_warehouse_list_data"><a href="javascript(0)" title="Edit" onclick="return en_ups_small_wd_edit_warehouse(' + WarehpuseDataId + ')"><img src="' + script.pluginsUrl + '/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/edit.png"></a><a href="javascript(0)" title="Delete" onclick="return en_ups_small_wd_delete_current_warehouse(' + WarehpuseDataId + ');"><img src="' + script.pluginsUrl + '/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/delete.png"></a></td>'); 392 393 jQuery('.warehouse_updated').show('slow').delay(5000).hide('slow'); 393 394 jQuery('.warehouse_deleted').css('display', 'none'); … … 414 415 * @returns {Boolean} 415 416 */ 416 if (typeof en_ wd_delete_current_warehouse != 'function')417 { 418 function en_ wd_delete_current_warehouse(e)417 if (typeof en_ups_small_wd_delete_current_warehouse != 'function') 418 { 419 function en_ups_small_wd_delete_current_warehouse(e) 419 420 { 420 421 var tab = get_parameter_by_name('tab'); 421 422 var postForm = { 422 'action': 'en iture_wd_delete_warehouse',423 'action': 'en_ups_small_wd_delete_warehouse', 423 424 'delete_id': e, 424 425 'tab': tab, 426 'wp_nonce': en_ups_small_wh_script.nonce 425 427 }; 426 428 … … 456 458 * @returns {Boolean} 457 459 */ 458 if (typeof eniture_wd_edit_warehouse != 'function') 459 { 460 function eniture_wd_edit_warehouse(e) 461 { 460 if (typeof en_ups_small_wd_edit_warehouse != 'function') 461 { 462 function en_ups_small_wd_edit_warehouse(e) 463 { 464 console.log('en_ups_small_wd_edit_warehouse'); 462 465 var postForm = { 463 'action': 'en iture_wd_edit_warehouse',466 'action': 'en_ups_small_wd_edit_warehouse', 464 467 'edit_id': e, 468 'wp_nonce': en_ups_small_wh_script.nonce 465 469 }; 466 470 jQuery.ajax({ … … 512 516 * @returns {Boolean} 513 517 */ 514 if (typeof en_ wd_save_dropship != 'function')515 { 516 function en_ wd_save_dropship()518 if (typeof en_ups_small_wd_save_dropship != 'function') 519 { 520 function en_ups_small_wd_save_dropship() 517 521 { 518 522 … … 533 537 534 538 var postForm = { 535 'action': 'en iture_wd_save_dropship',539 'action': 'en_ups_small_wd_save_dropship', 536 540 'dropship_id': jQuery('#edit_dropship_form_id').val(), 537 541 'dropship_city': city, … … 547 551 // preferred origin 548 552 'pref_loc_lfq': jQuery('#add_dropships #pref_loc_lfq').val(), 549 'pref_loc_spq': jQuery('#add_dropships #pref_loc_spq').val() 553 'pref_loc_spq': jQuery('#add_dropships #pref_loc_spq').val(), 554 'wp_nonce': en_ups_small_wh_script.nonce 550 555 }; 551 556 … … 581 586 582 587 } else if (data.update_qry == 1) { 583 jQuery('tr[id=row_' + WarehpuseDataId + ']').html('<td class="en_wd_dropship_list_data">' + data.nickname + '</td><td class="en_wd_dropship_list_data">' + data.origin_city + '</td><td class="en_wd_dropship_list_data">' + data.origin_state + '</td><td class="en_wd_dropship_list_data">' + data.origin_zip + '</td><td class="en_wd_dropship_list_data">' + data.origin_country + '</td><td class="en_wd_dropship_list_data"><a href="javascript(0)" title="Edit" onclick="return en iture_wd_edit_dropship(' + WarehpuseDataId + ')"><img src="' + script.pluginsUrl + '/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/edit.png"></a><a href="javascript(0)" title="Delete" onclick="return en_wd_delete_current_dropship(' + WarehpuseDataId + ');"><img src="' + script.pluginsUrl + '/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/delete.png"></a></td>');588 jQuery('tr[id=row_' + WarehpuseDataId + ']').html('<td class="en_wd_dropship_list_data">' + data.nickname + '</td><td class="en_wd_dropship_list_data">' + data.origin_city + '</td><td class="en_wd_dropship_list_data">' + data.origin_state + '</td><td class="en_wd_dropship_list_data">' + data.origin_zip + '</td><td class="en_wd_dropship_list_data">' + data.origin_country + '</td><td class="en_wd_dropship_list_data"><a href="javascript(0)" title="Edit" onclick="return en_ups_small_wd_edit_dropship(' + WarehpuseDataId + ')"><img src="' + script.pluginsUrl + '/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/edit.png"></a><a href="javascript(0)" title="Delete" onclick="return en_ups_small_wd_delete_current_dropship(' + WarehpuseDataId + ');"><img src="' + script.pluginsUrl + '/small-package-quotes-ups-edition/warehouse-dropship/wild/assets/images/delete.png"></a></td>'); 584 589 jQuery('.dropship_updated').show('slow').delay(5000).hide('slow'); 585 590 jQuery('.dropship_created').css('display', 'none'); … … 612 617 * @returns {Boolean} 613 618 */ 614 if (typeof en iture_wd_edit_dropship != 'function')615 { 616 function en iture_wd_edit_dropship(e)619 if (typeof en_ups_small_wd_edit_dropship != 'function') 620 { 621 function en_ups_small_wd_edit_dropship(e) 617 622 { 618 623 var postForm = { 619 'action': 'en iture_wd_edit_dropship',624 'action': 'en_ups_small_wd_edit_dropship', 620 625 'dropship_edit_id': e, 626 'wp_nonce': en_ups_small_wh_script.nonce 621 627 }; 622 628 jQuery.ajax({ … … 670 676 * @returns {Boolean} 671 677 */ 672 if (typeof en_ wd_delete_current_dropship != 'function')673 { 674 function en_ wd_delete_current_dropship(e)678 if (typeof en_ups_small_wd_delete_current_dropship != 'function') 679 { 680 function en_ups_small_wd_delete_current_dropship(e) 675 681 { 676 682 var id = e; … … 701 707 var tab = get_parameter_by_name('tab'); 702 708 var postForm = { 703 'action': 'en iture_wd_delete_dropship',709 'action': 'en_ups_small_wd_delete_dropship', 704 710 'dropship_delete_id': e, 705 711 'tab': tab, 712 'wp_nonce': en_ups_small_wh_script.nonce 706 713 }; 707 714 jQuery.ajax({ -
small-package-quotes-ups-edition/trunk/warehouse-dropship/wild/dropship/dropship_template.php
r3148641 r3237693 170 170 </script> 171 171 172 <div class="en_wd_setting_section ">172 <div class="en_wd_setting_section ups_small_wrapper"> 173 173 <a href="#delete_dropship_btn" class="delete_dropship_btn hide_drop_val"></a> 174 174 <div id="delete_dropship_btn" class="en_wd_warehouse_overlay"> … … 376 376 --> 377 377 <div class="form-btns"> 378 <input type="submit" name="en_wd_submit_dropship" value="Save" class="save_warehouse_form" onclick="return en_ wd_save_dropship();">378 <input type="submit" name="en_wd_submit_dropship" value="Save" class="save_warehouse_form" onclick="return en_ups_small_wd_save_dropship();"> 379 379 </div> 380 380 </form> -
small-package-quotes-ups-edition/trunk/warehouse-dropship/wild/includes/wild-delivery-save.php
r3147523 r3237693 25 25 add_action('wp_ajax_eniture_wd_get_address', array($this, 'eniture_get_address_api_ajax')); 26 26 27 add_action('wp_ajax_nopriv_eniture_wd_delete_dropship', array($this, 'eniture_delete_dropship_ajax')); 28 add_action('wp_ajax_eniture_wd_delete_dropship', array($this, 'eniture_delete_dropship_ajax')); 29 30 add_action('wp_ajax_nopriv_eniture_wd_save_warehouse', array($this, 'eniture_save_warehouse_ajax')); 31 add_action('wp_ajax_eniture_wd_save_warehouse', array($this, 'eniture_save_warehouse_ajax')); 32 33 add_action('wp_ajax_nopriv_eniture_wd_save_dropship', array($this, 'eniture_save_dropship_ajax')); 34 add_action('wp_ajax_eniture_wd_save_dropship', array($this, 'eniture_save_dropship_ajax')); 35 36 37 add_action('wp_ajax_nopriv_eniture_wd_edit_dropship', array($this, 'eniture_edit_dropship_ajax')); 38 add_action('wp_ajax_eniture_wd_edit_dropship', array($this, 'eniture_edit_dropship_ajax')); 39 40 add_action('wp_ajax_nopriv_eniture_wd_delete_warehouse', array($this, 'eniture_delete_warehouse_ajax')); 41 add_action('wp_ajax_eniture_wd_delete_warehouse', array($this, 'eniture_delete_warehouse_ajax')); 42 43 add_action('wp_ajax_nopriv_eniture_wd_edit_warehouse', array($this, 'eniture_edit_warehouse_ajax')); 44 add_action('wp_ajax_eniture_wd_edit_warehouse', array($this, 'eniture_edit_warehouse_ajax')); 27 // Warehouse actions 28 add_action('wp_ajax_nopriv_en_ups_small_wd_save_warehouse', array($this, 'eniture_save_warehouse_ajax')); 29 add_action('wp_ajax_en_ups_small_wd_save_warehouse', array($this, 'eniture_save_warehouse_ajax')); 30 31 add_action('wp_ajax_nopriv_en_ups_small_wd_edit_warehouse', array($this, 'eniture_edit_warehouse_ajax')); 32 add_action('wp_ajax_en_ups_small_wd_edit_warehouse', array($this, 'eniture_edit_warehouse_ajax')); 33 34 add_action('wp_ajax_nopriv_en_ups_small_wd_delete_warehouse', array($this, 'eniture_delete_warehouse_ajax')); 35 add_action('wp_ajax_en_ups_small_wd_delete_warehouse', array($this, 'eniture_delete_warehouse_ajax')); 36 37 // Dropship actions 38 add_action('wp_ajax_nopriv_en_ups_small_wd_save_dropship', array($this, 'eniture_save_dropship_ajax')); 39 add_action('wp_ajax_en_ups_small_wd_save_dropship', array($this, 'eniture_save_dropship_ajax')); 40 41 add_action('wp_ajax_nopriv_en_ups_small_wd_edit_dropship', array($this, 'eniture_edit_dropship_ajax')); 42 add_action('wp_ajax_en_ups_small_wd_edit_dropship', array($this, 'eniture_edit_dropship_ajax')); 43 44 add_action('wp_ajax_nopriv_en_ups_small_wd_delete_dropship', array($this, 'eniture_delete_dropship_ajax')); 45 add_action('wp_ajax_en_ups_small_wd_delete_dropship', array($this, 'eniture_delete_dropship_ajax')); 45 46 } 46 47 … … 168 169 function eniture_save_warehouse_ajax() 169 170 { 171 if (!current_user_can('manage_options') || !wp_verify_nonce($_POST['wp_nonce'], 'en_woo_wd_nonce')) { 172 echo wp_json_encode([]); 173 return; 174 } 175 170 176 global $wpdb; 171 177 $html = ""; … … 220 226 221 227 if (isset($validateData["city"])) { 222 $get_warehouse_id = (isset($_POST['origin_id']) && intval($_POST['origin_id'])) ? sanitize_text_field(wp_unslash($_POST['origin_id'])) : "";228 $get_warehouse_id = (isset($_POST['origin_id']) && intval($_POST['origin_id'])) ? intval($_POST['origin_id']) : ""; 223 229 if ($get_warehouse_id && (empty($get_warehouse) || (!empty($get_warehouse) && reset($get_warehouse)->id == $get_warehouse_id))) { 224 230 $update_qry = $wpdb->update( … … 257 263 function eniture_edit_warehouse_ajax() 258 264 { 265 if (!current_user_can('manage_options') || !wp_verify_nonce($_POST['wp_nonce'], 'en_woo_wd_nonce')) { 266 echo wp_json_encode([]); 267 return; 268 } 269 259 270 // Terminal phone number 260 271 global $wpdb; 261 $get_warehouse_id = (isset($_POST['edit_id']) && intval($_POST['edit_id'])) ? sanitize_text_field(wp_unslash($_POST['edit_id'])) : "";272 $get_warehouse_id = (isset($_POST['edit_id']) && intval($_POST['edit_id'])) ? intval($_POST['edit_id']) : ""; 262 273 $warehous_list = $wpdb->get_results( 263 274 $wpdb->prepare( … … 278 289 function eniture_delete_warehouse_ajax() 279 290 { 280 global $wpdb; 281 $get_warehouse_id = (isset($_POST['delete_id']) && intval($_POST['delete_id'])) ? sanitize_text_field(wp_unslash($_POST['delete_id'])) : ""; 291 if (!current_user_can('manage_options') || !wp_verify_nonce($_POST['wp_nonce'], 'en_woo_wd_nonce')) { 292 echo wp_json_encode([]); 293 return; 294 } 295 296 global $wpdb; 297 $get_warehouse_id = (isset($_POST['delete_id']) && intval($_POST['delete_id'])) ? intval($_POST['delete_id']) : ""; 282 298 $qry = $wpdb->delete($wpdb->prefix . 'warehouse', array('id' => $get_warehouse_id, 'location' => 'warehouse')); 283 299 … … 294 310 function eniture_save_dropship_ajax() 295 311 { 312 if (!current_user_can('manage_options') || !wp_verify_nonce($_POST['wp_nonce'], 'en_woo_wd_nonce')) { 313 echo wp_json_encode([]); 314 return; 315 } 316 296 317 global $wpdb; 297 318 $html = ""; … … 348 369 349 370 if (isset($validateData["city"])) { 350 $get_dropship_id = (isset($_POST['dropship_id']) && intval($_POST['dropship_id'])) ? sanitize_text_field(wp_unslash($_POST['dropship_id'])) : "";371 $get_dropship_id = (isset($_POST['dropship_id']) && intval($_POST['dropship_id'])) ? intval($_POST['dropship_id']) : ""; 351 372 352 373 if ($get_dropship_id != '' && (empty($get_dropship) || (!empty($get_dropship) && reset($get_dropship)->id == $get_dropship_id))) { … … 386 407 function eniture_edit_dropship_ajax() 387 408 { 409 if (!current_user_can('manage_options') || !wp_verify_nonce($_POST['wp_nonce'], 'en_woo_wd_nonce')) { 410 echo wp_json_encode([]); 411 return; 412 } 413 388 414 // Terminal phone number 389 415 global $wpdb; 390 $get_dropship_id = (isset($_POST['dropship_edit_id']) && intval($_POST['dropship_edit_id'])) ? sanitize_text_field(wp_unslash($_POST['dropship_edit_id'])) : "";416 $get_dropship_id = (isset($_POST['dropship_edit_id']) && intval($_POST['dropship_edit_id'])) ? intval($_POST['dropship_edit_id']) : ""; 391 417 $warehous_list = $wpdb->get_results( 392 418 $wpdb->prepare( … … 406 432 function eniture_delete_dropship_ajax() 407 433 { 408 409 global $wpdb; 410 411 $get_dropship_id = (isset($_POST['dropship_delete_id']) && intval($_POST['dropship_delete_id'])) ? sanitize_text_field(wp_unslash($_POST['dropship_delete_id'])) : ""; 434 if (!current_user_can('manage_options') || !wp_verify_nonce($_POST['wp_nonce'], 'en_woo_wd_nonce')) { 435 echo wp_json_encode([]); 436 return; 437 } 438 439 global $wpdb; 440 441 $get_dropship_id = (isset($_POST['dropship_delete_id']) && intval($_POST['dropship_delete_id'])) ? intval($_POST['dropship_delete_id']) : ""; 412 442 $dropship_id = isset($_POST['dropship_delete_id']) ? sanitize_text_field(wp_unslash($_POST['dropship_delete_id'])) : ""; 413 443 $get_dropship_array = array($dropship_id); -
small-package-quotes-ups-edition/trunk/warehouse-dropship/wild/warehouse/warehouse_template.php
r3148641 r3237693 167 167 }); 168 168 </script> 169 <div class="en_wd_setting_section ">169 <div class="en_wd_setting_section ups_small_wrapper"> 170 170 <h1>Warehouses</h1><br> 171 171 … … 357 357 --> 358 358 <div class="form-btns"> 359 <input type="submit" name="en_wd_submit_warehouse" value="Save" class="save_warehouse_form" onclick="return en_ wd_save_warehouse();">359 <input type="submit" name="en_wd_submit_warehouse" value="Save" class="save_warehouse_form" onclick="return en_ups_small_wd_save_warehouse();"> 360 360 </div> 361 361 </form>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)