Changeset 3782015
- Timestamp:
- 11/03/2026 02:29:27 PM (3 weeks ago)
- Location:
- woocommerce-ajax-cart
- Files:
-
- 30 added
- 9 edited
-
tags/1.5.2 (added)
-
tags/1.5.2/assets (added)
-
tags/1.5.2/assets/wac-cart-block-totals.js (added)
-
tags/1.5.2/assets/wac-cart-block.js (added)
-
tags/1.5.2/assets/wac-free-shipping-block.js (added)
-
tags/1.5.2/assets/wac-free-shipping.css (added)
-
tags/1.5.2/assets/wac-side-cart.css (added)
-
tags/1.5.2/assets/wac-side-cart.js (added)
-
tags/1.5.2/assets/wooajaxcart.css (added)
-
tags/1.5.2/assets/wooajaxcart.js (added)
-
tags/1.5.2/common (added)
-
tags/1.5.2/common/MHCommon.php (added)
-
tags/1.5.2/common/MHNotice.php (added)
-
tags/1.5.2/common/MHSettings.php (added)
-
tags/1.5.2/common/assets (added)
-
tags/1.5.2/common/assets/admin-settings.css (added)
-
tags/1.5.2/common/assets/admin-settings.js (added)
-
tags/1.5.2/common/assets/alert.png (added)
-
tags/1.5.2/common/assets/youtube.png (added)
-
tags/1.5.2/i18n (added)
-
tags/1.5.2/i18n/languages (added)
-
tags/1.5.2/i18n/languages/woocommerce-ajax-cart.pot (added)
-
tags/1.5.2/includes (added)
-
tags/1.5.2/includes/free-shipping.php (added)
-
tags/1.5.2/includes/side-cart.php (added)
-
tags/1.5.2/readme.txt (added)
-
tags/1.5.2/templates (added)
-
tags/1.5.2/templates/wac-qty-select.php (added)
-
tags/1.5.2/wooajaxcart.php (added)
-
trunk/assets/wac-cart-block-totals.js (added)
-
trunk/assets/wac-free-shipping-block.js (modified) (1 diff)
-
trunk/assets/wac-side-cart.js (modified) (3 diffs)
-
trunk/assets/wooajaxcart.js (modified) (11 diffs)
-
trunk/i18n/languages/woocommerce-ajax-cart.pot (modified) (5 diffs)
-
trunk/includes/free-shipping.php (modified) (3 diffs)
-
trunk/includes/side-cart.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/templates/wac-qty-select.php (modified) (2 diffs)
-
trunk/wooajaxcart.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woocommerce-ajax-cart/trunk/assets/wac-free-shipping-block.js
r3776669 r3782015 1 // The Cart block (rendered by WooCommerce in React, its data in the wc/store/cart store):2 // keeps the free shipping bar in step with the cart's totals.1 // The Cart block: keeps the free shipping bar in step with the cart's totals 2 // (the cart store and the money format: wac-cart-block-totals.js). 3 3 (function () { 4 4 var vars = window.wac_free_shipping; 5 5 var data = window.wp && window.wp.data; 6 if (!vars || !data || !(vars.threshold > 0)) { 6 var cart = window.wacCartBlockTotals; 7 if (!vars || !data || !cart || !(vars.threshold > 0)) { 7 8 return; 8 9 } 9 var STORE = 'wc/store/cart';10 // The cart store registers with the Cart block's own scripts: until then there is nothing to read.11 var store = function () {12 var s = data.select(STORE);13 return s && s.getCartData ? s : null;14 };15 var money = function (minor, totals) {16 var unit = totals.currency_minor_unit || 0;17 var value = (minor / Math.pow(10, unit)).toFixed(unit);18 var parts = value.split('.');19 parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, totals.currency_thousand_separator || '');20 return (totals.currency_prefix || '') + parts.join(totals.currency_decimal_separator || '.') + (totals.currency_suffix || '');21 };22 10 var render = function () { 23 11 var bar = document.querySelector('.wac-free-shipping-block'); 24 if (!bar || !store()) { 12 var store = cart.store(); 13 if (!bar || !store) { 25 14 return; 26 15 } 27 var totals = store ().getCartTotals();16 var totals = store.getCartTotals(); 28 17 if (!totals || totals.total_items === undefined) { 29 18 return; 30 19 } 31 20 var unit = totals.currency_minor_unit || 0; 32 var total = parseInt(totals.total_items, 10) - parseInt(totals.total_discount || 0, 10); 33 if (vars.incl_tax === 'yes') { 34 total += parseInt(totals.total_items_tax || 0, 10) - parseInt(totals.total_discount_tax || 0, 10); 35 } 21 var total = cart.itemsTotal(totals, vars.incl_tax); 36 22 var threshold = Math.round(vars.threshold * Math.pow(10, unit)); 37 23 var remaining = Math.max(0, threshold - total); 38 bar.hidden = (store ().getCartData().items || []).length === 0;24 bar.hidden = (store.getCartData().items || []).length === 0; 39 25 bar.classList.toggle('wac-free-shipping-done', remaining === 0); 40 bar.querySelector('.wac-free-shipping-text').textContent = remaining > 0 ? vars.spend_text.replace('%s', money(remaining, totals)) : vars.done_text;26 bar.querySelector('.wac-free-shipping-text').textContent = remaining > 0 ? vars.spend_text.replace('%s', cart.money(remaining, totals)) : vars.done_text; 41 27 bar.querySelector('.wac-free-shipping-track span').style.width = Math.min(100, Math.round(total / threshold * 100)) + '%'; 42 28 }; -
woocommerce-ajax-cart/trunk/assets/wac-side-cart.js
r3776669 r3782015 7 7 var $toggle = $('.wac-side-cart-toggle'); 8 8 var vars = window.wac_side_cart || {}; 9 // One of WooCommerce's wc-ajax endpoints (remove_from_cart, apply_coupon, remove_coupon). 10 var endpoint = function(name) { 11 return String(vars.wc_ajax_url || '').replace('%%endpoint%%', name); 12 }; 9 13 10 14 var open = function() { … … 91 95 92 96 // --- The coupon form: WooCommerce's own AJAX endpoints, as on its Cart page ---------------- 93 var endpoint = function(name) {94 return String(vars.wc_ajax_url || '').replace('%%endpoint%%', name);95 };96 97 var $notices = $panel.find('.wac-side-cart-notices'); 97 98 var showNotices = function(html) { … … 124 125 e.preventDefault(); 125 126 var $form = $(this); 126 var code = $.trim($form.find('.wac-coupon-code').val());127 var code = String($form.find('.wac-coupon-code').val() || '').trim(); // $.trim() is deprecated since jQuery 3.5 127 128 if ( !code ) { 128 129 $form.find('.wac-coupon-code').trigger('focus'); -
woocommerce-ajax-cart/trunk/assets/wooajaxcart.js
r2845536 r3782015 1 jQuery(document).ready(function($){ 2 // 'use strict'; 3 1 /** 2 * The classic Cart page: a quantity changed (typed, picked, or through the -/+ buttons) updates 3 * the cart by AJAX — WooCommerce's own "Update cart" button, clicked for the shopper. 4 * 5 * window.wacChange, window.wacRefreshCart and window.wacListenQtyButtons are public on purpose: 6 * the PRO replaces wacRefreshCart (its "faster AJAX" update) and theme snippets call them. 7 * 8 * Developer event: `wac_before_cart_update` (on document.body, with the quantity field) just 9 * before the cart update is sent. 10 */ 11 jQuery(function($){ 4 12 var wacUpdateTimeout = null; 5 6 wacChange = function(qtyInput) { 7 8 13 var wacGridPollPending = false; 14 15 window.wacChange = function(qtyInput) { 9 16 // ask user if they really want to remove this product 10 17 if ( ( wooajaxcart.confirm_zero_qty == 'yes' ) && !wacZeroQuantityCheck(qtyInput) ) { … … 14 21 // when qty is set to zero, then fires default woocommerce remove link 15 22 if ( qtyInput.val() == 0 ) { 16 var removeLink = qtyInput.closest('.cart_item').find('.product-remove a'); 17 removeLink.trigger('click'); 23 qtyInput.closest('.cart_item').find('.product-remove a').trigger('click'); 18 24 return false; 19 25 } … … 25 31 26 32 wacUpdateTimeout = setTimeout(function(){ 27 wacRefreshCart(qtyInput); 33 $(document.body).trigger('wac_before_cart_update', [ qtyInput ]); 34 window.wacRefreshCart(qtyInput); 28 35 }, wooajaxcart.ajax_timeout); 29 36 … … 31 38 }; 32 39 33 wacRefreshCart = function(qtyInput) { 34 40 window.wacRefreshCart = function(qtyInput) { 35 41 // some themes creates multiple cart forms so it will try to find the correct update button 36 if ( qtyInput.closest('.woocommerce-cart-form').length ) { 37 var mainSelector = qtyInput.closest('.woocommerce-cart-form'); 38 } 39 else { 40 var mainSelector = $(document); 41 } 42 42 var cartForm = qtyInput.closest('.woocommerce-cart-form'); 43 var mainSelector = cartForm.length ? cartForm : $(document); 44 43 45 // deal with update cart button 44 46 var updateButton = mainSelector.find("button[name='update_cart']:not(.dgfw-add-gift-button),input[name='update_cart']:not(.dgfw-add-gift-button)"); … … 48 50 .val( wooajaxcart.updating_text ) 49 51 .prop('disabled', true); 50 52 51 53 // change the Update cart button 52 54 $("a.checkout-button.wc-forward").addClass('disabled') … … 54 56 }; 55 57 56 // overrided by wac-js-calls.php 58 // The quantity back to the field's minimum (1 when it has none). 59 var wacResetNewQty = function(qtyInput) { 60 var min = qtyInput.attr('min'); 61 62 return ( min > 0 ) ? min : 1; 63 }; 64 65 // "Remove this item?" when the quantity goes to zero or the field is emptied; "Cancel" puts it back. 57 66 var wacZeroQuantityCheck = function(qtyInput) { 58 67 // when changes quantity to zero 59 68 if ( parseInt(qtyInput.val()) == 0 && !confirm(wooajaxcart.warn_remove_text) ) { 60 var newQty = wacResetNewQty(qtyInput); 61 qtyInput.val( newQty); 62 69 qtyInput.val( wacResetNewQty(qtyInput) ); 63 70 return false; 64 71 } … … 66 73 // when empty the quantity input 67 74 if ( qtyInput.val().length === 0 && !confirm(wooajaxcart.warn_remove_text) ) { 68 var newQty = wacResetNewQty(qtyInput); 69 qtyInput.val( newQty ).trigger('change'); 70 75 qtyInput.val( wacResetNewQty(qtyInput) ).trigger('change'); 71 76 return false; 72 77 } 73 78 74 79 return true; 75 };76 77 var wacResetNewQty = function(qtyInput) {78 var min = qtyInput.attr('min');79 80 if ( min != 'undefined' ) {81 var newQty = ( ( min > 0 ) ? min : 1 );82 }83 else {84 var newQty = 1;85 };86 87 return newQty;88 80 }; 89 81 90 82 var wacListenQtyChange = function() { 91 83 $(document).on('change', '.qty', function(e){ 84 var qtyInput = $(this); 85 92 86 // prevent troubles with WooCommerce Product Bundles plugin 93 87 if ( $('.bundle_add_to_cart_button').length ) { … … 96 90 97 91 // prevent to set invalid quantity on select 98 if ( $(this).is('select') && ( $(this).attr('max') > 0 ) &&99 ( parseInt( $(this).val()) > parseInt($(this).attr('max')) ) ) {100 $(this).val( $(this).attr('max') );92 if ( qtyInput.is('select') && ( qtyInput.attr('max') > 0 ) && 93 ( parseInt(qtyInput.val()) > parseInt(qtyInput.attr('max')) ) ) { 94 qtyInput.val( qtyInput.attr('max') ); 101 95 102 96 e.preventDefault(); … … 104 98 } 105 99 106 return w acChange( $(this));100 return window.wacChange( qtyInput ); 107 101 }); 108 102 }; … … 122 116 }; 123 117 124 wacListenQtyButtons = function() { 125 var fnIncrement = function(e){ 126 if ( $(this).hasClass('disabled') ) { 127 e.preventDefault(); 128 return false; 129 } 130 131 var inputQty = wacFindInputQty( $(this) ); 132 133 if ( inputQty.attr('max') != 'undefined' && parseFloat(inputQty.val()) >= parseFloat(inputQty.attr('max')) ) { 134 return false; 135 } 136 137 inputQty.val( function(i, oldval) { return ++oldval; }); 138 inputQty.trigger('change'); 139 140 return false; 141 }; 142 143 var fnDecrement = function(e){ 144 if ( $(this).hasClass('disabled') ) { 145 e.preventDefault(); 146 return false; 147 } 148 149 var inputQty = wacFindInputQty( $(this) ); 150 var oldVal = inputQty.val(); 151 152 if ( inputQty.attr('min') != 'undefined' && parseInt(inputQty.attr('min')) >= oldVal ) { 153 return false; 154 } 155 156 inputQty.val( --oldVal ); 157 inputQty.trigger('change'); 158 159 return false; 160 }; 161 118 // The -/+ buttons. A field with no max (or no min) is never capped: parseFloat() of a missing 119 // attribute is NaN, and any comparison with NaN is false. 120 var wacIncrement = function(e){ 121 if ( $(this).hasClass('disabled') ) { 122 e.preventDefault(); 123 return false; 124 } 125 126 var inputQty = wacFindInputQty( $(this) ); 127 128 if ( parseFloat(inputQty.val()) >= parseFloat(inputQty.attr('max')) ) { 129 return false; 130 } 131 132 inputQty.val( function(i, oldval) { return ++oldval; }); 133 inputQty.trigger('change'); 134 135 return false; 136 }; 137 138 var wacDecrement = function(e){ 139 if ( $(this).hasClass('disabled') ) { 140 e.preventDefault(); 141 return false; 142 } 143 144 var inputQty = wacFindInputQty( $(this) ); 145 var oldVal = inputQty.val(); 146 147 if ( parseInt(inputQty.attr('min')) >= oldVal ) { 148 return false; 149 } 150 151 inputQty.val( --oldVal ); 152 inputQty.trigger('change'); 153 154 return false; 155 }; 156 157 // Bound on the buttons themselves (a theme that stops the click on its way up still gets them) and 158 // delegated on the document (buttons drawn later). The direct handler returns false, which stops 159 // the click there, so one click never counts twice. 160 window.wacListenQtyButtons = function() { 162 161 if ( $('.wac-btn-inc').length ) { 163 162 // fix common style problem in single product page … … 165 164 $("<style type='text/css' id='wac-style-prod-qty'>.product .quantity { display: inline; float: none !important; margin-right: 0 !important; }</style>").appendTo('head'); 166 165 } 167 168 $('.wac-btn-inc').off('click.wac2910').on('click.wac2910', fnIncrement); 169 $('.wac-btn-sub').off('click.wac2911').on('click.wac2911', fnDecrement); 170 171 if ( $('.grid').length ) { 172 setTimeout(wacListenQtyButtons, 500); 173 } 174 } 175 176 $(document).off('click.wac3000').on('click.wac3000', '.wac-btn-inc', fnIncrement); 177 $(document).off('click.wac3001').on('click.wac3001', '.wac-btn-sub', fnDecrement); 166 167 $('.wac-btn-inc').off('click.wac2910').on('click.wac2910', wacIncrement); 168 $('.wac-btn-sub').off('click.wac2911').on('click.wac2911', wacDecrement); 169 170 // Grid themes draw their products after load: bind the new buttons every half second. 171 // One timer at a time — before, every cart fragments refresh started one more. 172 if ( $('.grid').length && !wacGridPollPending ) { 173 wacGridPollPending = true; 174 setTimeout(function(){ 175 wacGridPollPending = false; 176 window.wacListenQtyButtons(); 177 }, 500); 178 } 179 } 180 181 $(document).off('click.wac3000').on('click.wac3000', '.wac-btn-inc', wacIncrement); 182 $(document).off('click.wac3001').on('click.wac3001', '.wac-btn-sub', wacDecrement); 178 183 }; 179 184 180 185 // onload calls 181 186 wacListenQtyChange(); 182 w acListenQtyButtons();187 window.wacListenQtyButtons(); 183 188 184 189 $(document.body).on('wc_fragments_refreshed', function(){ 185 w acListenQtyButtons();190 window.wacListenQtyButtons(); 186 191 }); 187 192 188 $( document.body ).on( 'added_to_cart', function( event, fragments, cart_hash ){193 $(document.body).on('added_to_cart', function(){ 189 194 // prevent woocommerce to reload the page after Add to cart in certain conditions (outside Cart page) 190 195 // the window.location.reload() was defined in woo cart.js script 191 if ( $( '.woocommerce-cart-form').length == 0 ) {196 if ( $('.woocommerce-cart-form').length == 0 ) { 192 197 $('body').append('<div class="woocommerce-cart-form" style="display: none;"></div>'); 193 }198 } 194 199 }); 195 200 }); -
woocommerce-ajax-cart/trunk/i18n/languages/woocommerce-ajax-cart.pot
r3780066 r3782015 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Ajax Cart for WooCommerce 1.5. 1\n"5 "Project-Id-Version: Ajax Cart for WooCommerce 1.5.2\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woocommerce-ajax-cart\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2026-11-0 2T14:50:28+00:00\n"12 "POT-Creation-Date: 2026-11-03T14:28:43+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.12.0\n" … … 17 17 #. Plugin Name of the plugin 18 18 #: wooajaxcart.php 19 #: wooajaxcart.php: 4819 #: wooajaxcart.php:51 20 20 msgid "Ajax Cart for WooCommerce" 21 21 msgstr "" … … 107 107 108 108 #. translators: %s: the amount still to spend, with its currency 109 #: includes/free-shipping.php: 62110 #: includes/free-shipping.php:1 19109 #: includes/free-shipping.php:78 110 #: includes/free-shipping.php:137 111 111 #, php-format 112 112 msgid "Spend %s more for free shipping" 113 113 msgstr "" 114 114 115 #: includes/free-shipping.php: 63116 #: includes/free-shipping.php:1 20115 #: includes/free-shipping.php:79 116 #: includes/free-shipping.php:138 117 117 msgid "You have free shipping!" 118 118 msgstr "" 119 119 120 #: includes/side-cart.php: 89120 #: includes/side-cart.php:101 121 121 msgid "Your cart" 122 122 msgstr "" 123 123 124 #: includes/side-cart.php:1 02124 #: includes/side-cart.php:114 125 125 msgid "Open the cart" 126 126 msgstr "" 127 127 128 #: includes/side-cart.php:1 10129 #: wooajaxcart.php:14 0128 #: includes/side-cart.php:122 129 #: wooajaxcart.php:143 130 130 msgid "Cart" 131 131 msgstr "" 132 132 133 #: includes/side-cart.php:1 13133 #: includes/side-cart.php:125 134 134 msgid "Close the cart" 135 135 msgstr "" 136 136 137 #: includes/side-cart.php:1 48137 #: includes/side-cart.php:160 138 138 msgid "Coupon code" 139 139 msgstr "" 140 140 141 #: includes/side-cart.php:1 49141 #: includes/side-cart.php:161 142 142 msgid "Apply" 143 143 msgstr "" 144 144 145 #: includes/side-cart.php:1 59145 #: includes/side-cart.php:171 146 146 msgid "Applied" 147 147 msgstr "" 148 148 149 149 #. translators: %s: the coupon code 150 #: includes/side-cart.php:1 61150 #: includes/side-cart.php:173 151 151 #, php-format 152 152 msgid "Remove the coupon %s" … … 154 154 155 155 #. translators: %s: the coupon code 156 #: includes/side-cart.php:1 61156 #: includes/side-cart.php:173 157 157 msgid "Remove" 158 158 msgstr "" 159 159 160 #: includes/side-cart.php:1 65160 #: includes/side-cart.php:177 161 161 msgid "After discounts" 162 162 msgstr "" 163 163 164 #: includes/side-cart.php:2 11164 #: includes/side-cart.php:223 165 165 msgid "The coupon could not be applied. Please reload the page and try again." 166 166 msgstr "" 167 167 168 #: templates/wac-qty-select.php:26 168 #. translators: %s: the product's name. 169 #: templates/wac-qty-select.php:33 170 #, php-format 171 msgid "%s quantity" 172 msgstr "" 173 174 #. translators: %s: the product's name. 175 #: templates/wac-qty-select.php:33 176 msgid "Quantity" 177 msgstr "" 178 179 #: templates/wac-qty-select.php:51 169 180 msgctxt "Product quantity input tooltip" 170 181 msgid "Qty" 171 182 msgstr "" 172 183 173 #: wooajaxcart.php:6 5184 #: wooajaxcart.php:68 174 185 msgid "Display -/+ buttons around product quantity input" 175 186 msgstr "" 176 187 177 #: wooajaxcart.php:6 6178 #: wooajaxcart.php:7 2179 #: wooajaxcart.php: 78180 #: wooajaxcart.php: 87181 #: wooajaxcart.php:19 2188 #: wooajaxcart.php:69 189 #: wooajaxcart.php:75 190 #: wooajaxcart.php:81 191 #: wooajaxcart.php:90 192 #: wooajaxcart.php:195 182 193 msgid "General" 183 194 msgstr "" 184 195 185 #: wooajaxcart.php:7 1196 #: wooajaxcart.php:74 186 197 msgid "Show item quantity as select instead numeric field" 187 198 msgstr "" 188 199 189 #: wooajaxcart.php: 77200 #: wooajaxcart.php:80 190 201 msgid "Items to show on select" 191 202 msgstr "" 192 203 193 #: wooajaxcart.php:8 6204 #: wooajaxcart.php:89 194 205 msgid "Show user confirmation when change item quantity to zero or empty" 195 206 msgstr "" 196 207 197 #: wooajaxcart.php:9 2208 #: wooajaxcart.php:95 198 209 msgid "Enable the side cart: a cart that slides in from the side (or opens as a popup), on every page but the cart and checkout" 199 210 msgstr "" 200 211 201 #: wooajaxcart.php:9 3202 #: wooajaxcart.php: 99203 #: wooajaxcart.php:10 6204 #: wooajaxcart.php:11 3205 #: wooajaxcart.php:12 0206 #: wooajaxcart.php:13 0207 #: wooajaxcart.php:13 6208 #: wooajaxcart.php:1 48209 #: wooajaxcart.php:1 58210 #: wooajaxcart.php:16 5211 #: wooajaxcart.php:17 2212 #: wooajaxcart.php:96 213 #: wooajaxcart.php:102 214 #: wooajaxcart.php:109 215 #: wooajaxcart.php:116 216 #: wooajaxcart.php:123 217 #: wooajaxcart.php:133 218 #: wooajaxcart.php:139 219 #: wooajaxcart.php:151 220 #: wooajaxcart.php:161 221 #: wooajaxcart.php:168 222 #: wooajaxcart.php:175 212 223 msgid "Side cart" 213 224 msgstr "" 214 225 215 #: wooajaxcart.php: 98226 #: wooajaxcart.php:101 216 227 msgid "Open the side cart when a product is added to the cart" 217 228 msgstr "" 218 229 219 #: wooajaxcart.php:10 5230 #: wooajaxcart.php:108 220 231 msgid "Show a floating cart button with the item count" 221 232 msgstr "" 222 233 223 #: wooajaxcart.php:11 2234 #: wooajaxcart.php:115 224 235 msgid "Show a coupon form in the side cart (when coupons are enabled in WooCommerce)" 225 236 msgstr "" 226 237 227 #: wooajaxcart.php:1 19238 #: wooajaxcart.php:122 228 239 msgid "Side cart style: a drawer that slides in from the side, or a popup in the middle of the screen" 229 240 msgstr "" 230 241 231 #: wooajaxcart.php:12 4242 #: wooajaxcart.php:127 232 243 msgid "Drawer" 233 244 msgstr "" 234 245 235 #: wooajaxcart.php:12 5246 #: wooajaxcart.php:128 236 247 msgid "Popup" 237 248 msgstr "" 238 249 239 #: wooajaxcart.php:1 29250 #: wooajaxcart.php:132 240 251 msgid "Accent colour (floating button, checkout button, progress bar) — empty: the default colours" 241 252 msgstr "" 242 253 243 #: wooajaxcart.php:13 5254 #: wooajaxcart.php:138 244 255 msgid "Floating button icon" 245 256 msgstr "" 246 257 247 #: wooajaxcart.php:14 1258 #: wooajaxcart.php:144 248 259 msgid "Cart (outline)" 249 260 msgstr "" 250 261 251 #: wooajaxcart.php:14 2262 #: wooajaxcart.php:145 252 263 msgid "Shopping bag" 253 264 msgstr "" 254 265 255 #: wooajaxcart.php:14 3266 #: wooajaxcart.php:146 256 267 msgid "Basket" 257 268 msgstr "" 258 269 259 #: wooajaxcart.php:1 47270 #: wooajaxcart.php:150 260 271 msgid "Floating button position" 261 272 msgstr "" 262 273 263 #: wooajaxcart.php:15 2274 #: wooajaxcart.php:155 264 275 msgid "Bottom right" 265 276 msgstr "" 266 277 267 #: wooajaxcart.php:15 3278 #: wooajaxcart.php:156 268 279 msgid "Bottom left" 269 280 msgstr "" 270 281 271 #: wooajaxcart.php:1 57282 #: wooajaxcart.php:160 272 283 msgid "Side cart title (empty: \"Your cart\")" 273 284 msgstr "" 274 285 275 #: wooajaxcart.php:16 4286 #: wooajaxcart.php:167 276 287 msgid "Checkout button text (empty: WooCommerce's \"Checkout\")" 277 288 msgstr "" 278 289 279 #: wooajaxcart.php:17 1290 #: wooajaxcart.php:174 280 291 msgid "Empty cart text (empty: WooCommerce's \"No products in the cart.\")" 281 292 msgstr "" 282 293 283 #: wooajaxcart.php:1 78294 #: wooajaxcart.php:181 284 295 msgid "Show a free shipping progress bar in the side cart, Mini-Cart, Cart page and Cart block" 285 296 msgstr "" 286 297 287 #: wooajaxcart.php:1 79288 #: wooajaxcart.php:18 5298 #: wooajaxcart.php:182 299 #: wooajaxcart.php:188 289 300 msgid "Free shipping bar" 290 301 msgstr "" 291 302 292 #: wooajaxcart.php:18 4303 #: wooajaxcart.php:187 293 304 msgid "Order amount for free shipping (empty: read from the free shipping method of the shopper's shipping zone)" 294 305 msgstr "" 295 306 296 #: wooajaxcart.php:19 1307 #: wooajaxcart.php:194 297 308 msgid "AJAX timeout in milliseconds to refresh the cart on change" 298 309 msgstr "" 299 310 300 #: wooajaxcart.php:25 1301 #: wooajaxcart.php:26 1311 #: wooajaxcart.php:254 312 #: wooajaxcart.php:264 302 313 msgid "Are you sure you want to remove this item from cart?" 303 314 msgstr "" 304 315 305 #: wooajaxcart.php:26 0316 #: wooajaxcart.php:263 306 317 msgid "Updating..." 307 318 msgstr "" -
woocommerce-ajax-cart/trunk/includes/free-shipping.php
r3780066 r3782015 18 18 function wac_free_shipping_threshold() { 19 19 $manual = (float) str_replace(',', '.', (string) wac_option('free_shipping_amount')); 20 if ( $manual > 0 ) { 21 return $manual; 22 } 20 $threshold = ( $manual > 0 ) ? $manual : wac_free_shipping_zone_minimum(); 21 22 /** 23 * Filters the order amount that gives free shipping, as the bars show it (the side cart, 24 * the Mini-Cart, the Cart page and the Cart block). 0 hides the free shipping bar. 25 * A multi-currency shop can convert it to the shopper's currency here. 26 * 27 * @since 1.5.2 28 * 29 * @param float $threshold The amount: the "Order amount for free shipping" setting, or the 30 * minimum of the free shipping method of the shopper's shipping zone. 31 */ 32 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- wac_ is this plugin's prefix, the same in the free plugin and its PRO 33 return (float) apply_filters('wac_free_shipping_threshold', $threshold); 34 } 35 36 // The minimum order of the free shipping method in the shopper's shipping zone, 0 when there is none. 37 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- wac_ is this plugin's prefix, the same in the free plugin and its PRO 38 function wac_free_shipping_zone_minimum() { 23 39 if ( !function_exists('WC') || !WC()->cart || !class_exists('WC_Shipping_Zones') ) { 24 40 return 0; … … 105 121 $base = plugin_basename(WAC_BASE_FILE); 106 122 107 // Registered always: another bar (the PRO's rewards) is drawn with the same styles. 123 // Registered always: another bar (the PRO's rewards) is drawn with the same styles, and reads 124 // the Cart block's totals with the same script. 108 125 wp_register_style('wac-free-shipping', plugins_url('assets/wac-free-shipping.css', $base), array('wooajaxcart'), (string) filemtime($dir . 'assets/wac-free-shipping.css')); 126 wp_register_script('wac-cart-block-totals', plugins_url('assets/wac-cart-block-totals.js', $base), array('wp-data'), (string) filemtime($dir . 'assets/wac-cart-block-totals.js'), true); 109 127 if ( wac_option('free_shipping_bar') == 'yes' ) { 110 128 wp_enqueue_style('wac-free-shipping'); … … 112 130 113 131 if ( is_cart() && has_block('woocommerce/cart') && wac_free_shipping_block_enabled() ) { 114 wp_enqueue_script('wac-free-shipping-block', plugins_url('assets/wac-free-shipping-block.js', $base), array('wp-data' ), (string) filemtime($dir . 'assets/wac-free-shipping-block.js'), true);132 wp_enqueue_script('wac-free-shipping-block', plugins_url('assets/wac-free-shipping-block.js', $base), array('wp-data', 'wac-cart-block-totals'), (string) filemtime($dir . 'assets/wac-free-shipping-block.js'), true); 115 133 wp_localize_script('wac-free-shipping-block', 'wac_free_shipping', array( 116 134 'threshold' => wac_free_shipping_threshold(), -
woocommerce-ajax-cart/trunk/includes/side-cart.php
r3780066 r3782015 13 13 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- wac_ is this plugin's prefix, the same in the free plugin and its PRO; the name is kept for the code and extensions that call it 14 14 function wac_side_cart_enabled() { 15 return ( wac_option('side_cart') == 'yes' ) && function_exists('WC') && ! is_cart() && ! is_checkout(); 15 $enabled = ( wac_option('side_cart') == 'yes' ) && function_exists('WC') && ! is_cart() && ! is_checkout(); 16 17 /** 18 * Filters whether the side cart (and its floating button) is on this page — to leave it off 19 * a landing page, or to show it to some shoppers only. 20 * 21 * @since 1.5.2 22 * 23 * @param bool $enabled True when the "Enable the side cart" setting is on and the page is 24 * not the Cart or the Checkout. 25 */ 26 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- wac_ is this plugin's prefix, the same in the free plugin and its PRO 27 return (bool) apply_filters('wac_side_cart_enabled', $enabled); 16 28 } 17 29 -
woocommerce-ajax-cart/trunk/readme.txt
r3780066 r3782015 4 4 Requires at least: 5.0 5 5 Tested up to: 7.1 6 Stable tag: 1.5. 16 Stable tag: 1.5.2 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 61 61 3. Done. This plugin no requires extra configurations to work 62 62 63 == Frequently Asked Questions == 64 65 = Can a developer change what the plugin does? = 66 67 Yes, with WordPress hooks (filters and actions) and JavaScript events, in a child theme's functions.php or a small plugin: 68 69 * `wac_side_cart_enabled` (filter, bool `$enabled`): the side cart and its floating button on or off on the current page. 70 * `wac_side_cart_before_items` / `wac_side_cart_after_items` (actions): print your own HTML in the side cart, above or below its items. 71 * `wac_free_shipping_threshold` (filter, float `$threshold`): the order amount that gives free shipping, as the bars show it — for example converted to the shopper's currency; 0 hides the bar. 72 * `wac_progress_bar_html` (filter, string `$html`): the free shipping bar printed in the side cart, Mini-Cart and classic Cart. 73 * `wac_free_shipping_block_enabled` (filter, bool `$enabled`): whether the Cart block gets the free shipping bar. 74 * `wac_quantity_div` (filter: `$html`, `$cart_item_key`, `$cart_item`, `$original_html`): a cart item's quantity field with its -/+ buttons. 75 * `wac_button_link` (filter: `$html`, `$label`, `$identifier` — `sub` or `inc`): the HTML of a - or + button. 76 * `wac_template_file` (filter: `$located`, `$template_name`, `$args`): the quantity dropdown template ("Show item quantity as select"). 77 * `wac_frontend_vars` (filter, array `$vars`): the settings and texts the cart script reads. 78 * `mh_wac_settings` (filter, array `$settings`): the settings, with their defaults. 79 * `wac_before_cart_update` (JavaScript event on `document.body`, with the quantity field): just before a changed quantity updates the classic cart. 80 63 81 == Screenshots == 64 82 … … 70 88 71 89 == Changelog == 90 91 = 1.5.2 = 92 * Developers: new hooks — `wac_side_cart_enabled` (the side cart on or off on a page), `wac_free_shipping_threshold` (the free shipping amount, for example in the shopper's currency), more arguments on `wac_quantity_div` and `wac_button_link`, and the JavaScript event `wac_before_cart_update`; every hook is listed in the FAQ (2026-11-03) 93 * Hardened: the plugin declares to WooCommerce that it works with the Cart and Checkout blocks (WooCommerce 8.x listed a plugin that did not as incompatible) (2026-11-03) 94 * Fixed: on themes with a grid product layout, every cart refresh started one more half-second timer re-binding the -/+ buttons; there is one timer now (2026-11-03) 95 * Hardened: the scripts cleaned up, with no change in what they do — the functions other code calls are declared on purpose, repeated code merged, the deprecated `$.trim()` (jQuery 3.5) replaced, and the Cart block's bars read the cart's totals through one shared script (2026-11-03) 96 * Fixed: WooCommerce's System Status no longer lists the plugin's quantity dropdown template as out of date ("version 4.0.0 is out of date") — it follows WooCommerce's current quantity template: a label for screen readers, the field's id and WooCommerce's classes (2026-11-03) 72 97 73 98 = 1.5.1 = -
woocommerce-ajax-cart/trunk/templates/wac-qty-select.php
r3780066 r3782015 1 1 <?php 2 2 /** 3 * Cart Page3 * Product quantity inputs, as a dropdown 4 4 * 5 * Custom template for plugin Ajax Cart for WooCommerce 5 * Ajax Cart for WooCommerce's copy of WooCommerce's global/quantity-input.php, used 6 * when "Show quantity as select" is on: the same wrapper, label, id and classes, with 7 * a <select> in place of the number input. WooCommerce's before/after field hooks are 8 * left out on purpose: they are where the −/+ buttons (this plugin's PRO, many themes) 9 * go, and a button stepping a dropdown past its options breaks it. 6 10 * 7 11 * HOWEVER, on occasion WooCommerce will need to update template files and you … … 11 15 * the readme will list any important changes. 12 16 * 13 * @see https://docs.woocommerce.com/document/template-structure/ 14 * @package WooCommerce/Templates 15 * @version 4.0.0 17 * @see https://woocommerce.com/document/template-structure/ 18 * @package WooCommerce\Templates 19 * @version 11.4.0 20 * 21 * @var bool $readonly If the input should be set to readonly mode. 22 * @var string $type The input type attribute. 16 23 */ 17 24 18 25 defined( 'ABSPATH' ) || exit; 19 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- a template variable, local to wc_get_template()'s scope, not a global 20 $min_value = isset($min_value) ? $min_value : 0; 21 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- a template variable, local to wc_get_template()'s scope, not a global 22 $step = isset($step) ? $step : 1; 26 // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- template variables, local to wc_get_template()'s scope, not globals 27 $min_value = isset( $min_value ) ? $min_value : 0; 28 $step = isset( $step ) ? $step : 1; 29 $input_id = isset( $input_id ) ? $input_id : uniqid( 'quantity_' ); 30 $classes = ! empty( $classes ) ? (array) $classes : array( 'input-text', 'qty', 'text' ); 31 $readonly = ! empty( $readonly ); 32 /* translators: %s: the product's name. */ 33 $label = ! empty( $args['product_name'] ) ? sprintf( esc_html__( '%s quantity', 'woocommerce-ajax-cart' ), wp_strip_all_tags( $args['product_name'] ) ) : esc_html__( 'Quantity', 'woocommerce-ajax-cart' ); 23 34 ?> 24 35 <div class="quantity"> 25 <select name="<?php echo esc_attr( $input_name ); ?>" 26 title="<?php echo esc_attr_x( 'Qty', 'Product quantity input tooltip', 'woocommerce-ajax-cart' ) ?>" 27 class="input-text qty text" 28 max="<?php echo esc_attr( wac_option('select_items') ); ?>"> 29 <?php if ( !empty($dropdown_steps) ): ?> 30 <?php foreach ( $dropdown_steps as $step ): // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- a template variable, local to wc_get_template()'s scope, not a global ?> 31 <option <?php selected( $input_value, $step ); ?> value="<?php echo esc_attr( $step ); ?>"> 32 <?php echo esc_html( $step ); ?> 33 </option> 34 <?php endforeach; ?> 35 <?php else: ?> 36 <?php for ( $i = $min_value; $i <= wac_option('select_items') && ( empty($max_value) || $i <= $max_value ); $i += $step ): // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- a template variable, local to wc_get_template()'s scope, not a global ?> 37 <option <?php selected( $input_value, $i ); ?> value="<?php echo esc_attr( $i ); ?>"> 38 <?php echo esc_html( $i ); ?> 39 </option> 40 <?php endfor; ?> 41 <?php endif; ?> 42 </select> 36 <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_html( $label ); ?></label> 37 <?php if ( $readonly ) : ?> 38 <input type="<?php echo esc_attr( isset( $type ) ? $type : 'number' ); ?>" readonly="readonly" 39 id="<?php echo esc_attr( $input_id ); ?>" 40 class="<?php echo esc_attr( join( ' ', $classes ) ); ?>" 41 name="<?php echo esc_attr( $input_name ); ?>" 42 value="<?php echo esc_attr( $input_value ); ?>" 43 min="<?php echo esc_attr( $min_value ); ?>" 44 <?php if ( 0 < $max_value ) : ?> 45 max="<?php echo esc_attr( $max_value ); ?>" 46 <?php endif; ?> 47 /> 48 <?php else : ?> 49 <select name="<?php echo esc_attr( $input_name ); ?>" 50 id="<?php echo esc_attr( $input_id ); ?>" 51 title="<?php echo esc_attr_x( 'Qty', 'Product quantity input tooltip', 'woocommerce-ajax-cart' ); ?>" 52 class="<?php echo esc_attr( join( ' ', $classes ) ); ?>" 53 max="<?php echo esc_attr( wac_option( 'select_items' ) ); ?>"> 54 <?php if ( ! empty( $dropdown_steps ) ) : ?> 55 <?php foreach ( $dropdown_steps as $step ) : ?> 56 <option <?php selected( $input_value, $step ); ?> value="<?php echo esc_attr( $step ); ?>"> 57 <?php echo esc_html( $step ); ?> 58 </option> 59 <?php endforeach; ?> 60 <?php else : ?> 61 <?php for ( $i = $min_value; $i <= wac_option( 'select_items' ) && ( empty( $max_value ) || $max_value < 0 || $i <= $max_value ); $i += $step ) : ?> 62 <option <?php selected( $input_value, $i ); ?> value="<?php echo esc_attr( $i ); ?>"> 63 <?php echo esc_html( $i ); ?> 64 </option> 65 <?php endfor; ?> 66 <?php endif; ?> 67 </select> 68 <?php endif; ?> 43 69 </div> 70 <?php 71 // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -
woocommerce-ajax-cart/trunk/wooajaxcart.php
r3780066 r3782015 4 4 Plugin URI: https://wordpress.org/plugins/woocommerce-ajax-cart/ 5 5 Description: Updates the WooCommerce cart with AJAX as soon as a quantity changes — no "Update cart" click needed 6 Version: 1.5. 16 Version: 1.5.2 7 7 Author: Moises Heberle 8 8 Author URI: https://mhtec.org/contact/ … … 35 35 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { 36 36 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); 37 // The Cart and Checkout blocks: the side cart, the free shipping bar and the removal 38 // confirmation work on them too (the block cart updates its quantities by itself). 39 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, true ); 37 40 } 38 41 } ); … … 285 288 $input = str_replace(array('<div class="quantity">', '</div>'), array('', ''), $inputDiv); 286 289 $newDiv = '<div class="quantity wac-quantity">' . $minus . $input . $plus . '</div>'; 287 288 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- public hook name kept for compatibility (the PRO and other extensions hook into it) 289 return apply_filters('wac_quantity_div', $newDiv); 290 }; 290 291 /** 292 * Filters a cart item's quantity field with its -/+ buttons, on the classic Cart page. 293 * 294 * @since 1.5.2 The $cart_item_key, $cart_item and $original_html parameters. 295 * 296 * @param string $html The field between its buttons, in `<div class="quantity wac-quantity">`. 297 * @param string $cart_item_key The cart item's key. 298 * @param array|null $cart_item The cart item. 299 * @param string $original_html WooCommerce's field, without the buttons. 300 */ 301 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- public hook name kept for compatibility (the PRO and other extensions hook into it) 302 return apply_filters('wac_quantity_div', $newDiv, $cart_item_key, $cart_item, $inputDiv); 303 } 291 304 292 305 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- wac_ is this plugin's prefix, the same in the free plugin and its PRO; the name is kept for the code and extensions that call it … … 296 309 $html .= '</a>'; 297 310 298 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- public hook name kept for compatibility (the PRO and other extensions hook into it) 299 return apply_filters('wac_button_link', $html); 311 /** 312 * Filters the HTML of a - or + quantity button (Cart page; with the PRO, the product, 313 * shop and Mini-Cart quantities too). Keep its `wac-qty-button wac-btn-sub|inc` classes: 314 * the script finds the buttons by them. 315 * 316 * @since 1.5.2 The $label and $identifier parameters. 317 * 318 * @param string $html The button: `<a href="" class="wac-qty-button wac-btn-…">`. 319 * @param string $label Its text: "-" or "+". 320 * @param string $identifier "sub" (the - button) or "inc" (the + button). 321 */ 322 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- public hook name kept for compatibility (the PRO and other extensions hook into it) 323 return apply_filters('wac_button_link', $html, $label, $identifier); 300 324 } 301 325
Note:
See TracChangeset
for help on using the changeset viewer.