PluginProbe
Route ‑ Shipping Protection / 2.4.19
Route ‑ Shipping Protection v2.4.19
2.4.19 2.4.18 2.4.17 2.4.16 2.4.15 2.4.14 2.4.13 2.4.12 2.4.11 2.4.10 2.4.9 2.4.8 2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.2.4 2.2.5 2.2.6 2.2.8 2.2.9 2.3.0 2.3.1 All 153 releases
← All changes | admin/js/routeapp-admin.js +58 -0 2.4.3 → 2.4.19 View file →
@@ -48,8 +48,58 @@
48 48 }
49 49 return "";
50 50 }
51 51
52 + function isSaveOrderItemsRequest(settings) {
53 + if (!settings || !settings.data) {
54 + return false;
55 + }
56 +
57 + if (typeof settings.data === 'string') {
58 + try {
59 + return new URLSearchParams(settings.data).get('action') === 'woocommerce_save_order_items';
60 + } catch (e) {
61 + return settings.data.indexOf('action=woocommerce_save_order_items') !== -1;
62 + }
63 + }
64 +
65 + if (typeof settings.data === 'object') {
66 + return settings.data.action === 'woocommerce_save_order_items';
67 + }
68 +
69 + return false;
70 + }
71 +
72 + function refreshRouteFeeButton() {
73 + if (typeof woocommerce_admin_meta_boxes === 'undefined') {
74 + return;
75 + }
76 +
77 + var data = {
78 + action: 'routeapp_refresh_admin_fee_button',
79 + security: woocommerce_admin_meta_boxes.order_item_nonce,
80 + order_id: woocommerce_admin_meta_boxes.post_id
81 + };
82 +
83 + $.post(
84 + woocommerce_admin_meta_boxes.ajax_url,
85 + data,
86 + function( response ) {
87 + if (!response.success) {
88 + return;
89 + }
90 +
91 + $('#add-route-fee, #remove-route-fee').remove();
92 +
93 + if (response.data && response.data.html) {
94 + $('.wc-order-bulk-actions .add-items .calculate-action').first().before(response.data.html);
95 + }
96 + }
97 + ).fail(function(xhr) {
98 + console.error('Failed to refresh Route fee button.', xhr);
99 + });
100 + }
101 +
52 102 $(document).ready(function () {
53 103 $('.routeapp-redirect-countdown').each(function () {
54 104 var $wrap = $(this);
55 105 var mode = $wrap.data('countdown-mode') || 'once';
@@ -153,8 +203,16 @@
153 203 }
154 204 }
155 205 );
156 206
207 + });
208 +
209 + $(document.body).on('order-totals-recalculate-success', refreshRouteFeeButton);
210 +
211 + $(document).ajaxSuccess(function(event, xhr, settings) {
212 + if (isSaveOrderItemsRequest(settings)) {
213 + refreshRouteFeeButton();
214 + }
157 215 });
158 216
159 217 })
160 218