Plugin Directory

Changeset 3782015


Ignore:
Timestamp:
11/03/2026 02:29:27 PM (3 weeks ago)
Author:
moiseh
Message:

Release 1.5.2

Location:
woocommerce-ajax-cart
Files:
30 added
9 edited

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).
    33(function () {
    44    var vars = window.wac_free_shipping;
    55    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)) {
    78        return;
    89    }
    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     };
    2210    var render = function () {
    2311        var bar = document.querySelector('.wac-free-shipping-block');
    24         if (!bar || !store()) {
     12        var store = cart.store();
     13        if (!bar || !store) {
    2514            return;
    2615        }
    27         var totals = store().getCartTotals();
     16        var totals = store.getCartTotals();
    2817        if (!totals || totals.total_items === undefined) {
    2918            return;
    3019        }
    3120        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);
    3622        var threshold = Math.round(vars.threshold * Math.pow(10, unit));
    3723        var remaining = Math.max(0, threshold - total);
    38         bar.hidden = (store().getCartData().items || []).length === 0;
     24        bar.hidden = (store.getCartData().items || []).length === 0;
    3925        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;
    4127        bar.querySelector('.wac-free-shipping-track span').style.width = Math.min(100, Math.round(total / threshold * 100)) + '%';
    4228    };
  • woocommerce-ajax-cart/trunk/assets/wac-side-cart.js

    r3776669 r3782015  
    77    var $toggle = $('.wac-side-cart-toggle');
    88    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    };
    913
    1014    var open = function() {
    … …  
    9195
    9296    // --- 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     };
    9697    var $notices = $panel.find('.wac-side-cart-notices');
    9798    var showNotices = function(html) {
    … …  
    124125        e.preventDefault();
    125126        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
    127128        if ( !code ) {
    128129            $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 */
     11jQuery(function($){
    412    var wacUpdateTimeout = null;
    5 
    6     wacChange = function(qtyInput) {
    7 
    8 
     13    var wacGridPollPending = false;
     14
     15    window.wacChange = function(qtyInput) {
    916        // ask user if they really want to remove this product
    1017        if ( ( wooajaxcart.confirm_zero_qty == 'yes' ) && !wacZeroQuantityCheck(qtyInput) ) {
    … …  
    1421        // when qty is set to zero, then fires default woocommerce remove link
    1522        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');
    1824            return false;
    1925        }
    … …  
    2531
    2632        wacUpdateTimeout = setTimeout(function(){
    27             wacRefreshCart(qtyInput);
     33            $(document.body).trigger('wac_before_cart_update', [ qtyInput ]);
     34            window.wacRefreshCart(qtyInput);
    2835        }, wooajaxcart.ajax_timeout);
    2936
    … …  
    3138    };
    3239
    33     wacRefreshCart = function(qtyInput) {
    34 
     40    window.wacRefreshCart = function(qtyInput) {
    3541        // 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
    4345        // deal with update cart button
    4446        var updateButton = mainSelector.find("button[name='update_cart']:not(.dgfw-add-gift-button),input[name='update_cart']:not(.dgfw-add-gift-button)");
    … …  
    4850                    .val( wooajaxcart.updating_text )
    4951                    .prop('disabled', true);
    50        
     52
    5153        // change the Update cart button
    5254        $("a.checkout-button.wc-forward").addClass('disabled')
    … …  
    5456    };
    5557
    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.
    5766    var wacZeroQuantityCheck = function(qtyInput) {
    5867        // when changes quantity to zero
    5968        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) );
    6370            return false;
    6471        }
    … …  
    6673        // when empty the quantity input
    6774        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');
    7176            return false;
    7277        }
    7378
    7479        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;
    8880    };
    8981
    9082    var wacListenQtyChange = function() {
    9183        $(document).on('change', '.qty', function(e){
     84            var qtyInput = $(this);
     85
    9286            // prevent troubles with WooCommerce Product Bundles plugin
    9387            if ( $('.bundle_add_to_cart_button').length ) {
    … …  
    9690
    9791            // 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') );
    10195
    10296                e.preventDefault();
    … …  
    10498            }
    10599
    106             return wacChange( $(this) );
     100            return window.wacChange( qtyInput );
    107101        });
    108102    };
    … …  
    122116    };
    123117
    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() {
    162161        if ( $('.wac-btn-inc').length ) {
    163162            // fix common style problem in single product page
    … …  
    165164                $("<style type='text/css' id='wac-style-prod-qty'>.product .quantity { display: inline; float: none !important; margin-right: 0 !important; }</style>").appendTo('head');
    166165            }
    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);
    178183    };
    179184
    180185    // onload calls
    181186    wacListenQtyChange();
    182     wacListenQtyButtons();
     187    window.wacListenQtyButtons();
    183188
    184189    $(document.body).on('wc_fragments_refreshed', function(){
    185         wacListenQtyButtons();
     190        window.wacListenQtyButtons();
    186191    });
    187192
    188     $( document.body ).on( 'added_to_cart', function( event, fragments, cart_hash ) {
     193    $(document.body).on('added_to_cart', function(){
    189194        // prevent woocommerce to reload the page after Add to cart in certain conditions (outside Cart page)
    190195        // 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 ) {
    192197            $('body').append('<div class="woocommerce-cart-form" style="display: none;"></div>');
    193                 }
     198        }
    194199    });
    195200});
  • woocommerce-ajax-cart/trunk/i18n/languages/woocommerce-ajax-cart.pot

    r3780066 r3782015  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Ajax Cart for WooCommerce 1.5.1\n"
     5"Project-Id-Version: Ajax Cart for WooCommerce 1.5.2\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woocommerce-ajax-cart\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    … …  
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2026-11-02T14:50:28+00:00\n"
     12"POT-Creation-Date: 2026-11-03T14:28:43+00:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.12.0\n"
    … …  
    1717#. Plugin Name of the plugin
    1818#: wooajaxcart.php
    19 #: wooajaxcart.php:48
     19#: wooajaxcart.php:51
    2020msgid "Ajax Cart for WooCommerce"
    2121msgstr ""
    … …  
    107107
    108108#. translators: %s: the amount still to spend, with its currency
    109 #: includes/free-shipping.php:62
    110 #: includes/free-shipping.php:119
     109#: includes/free-shipping.php:78
     110#: includes/free-shipping.php:137
    111111#, php-format
    112112msgid "Spend %s more for free shipping"
    113113msgstr ""
    114114
    115 #: includes/free-shipping.php:63
    116 #: includes/free-shipping.php:120
     115#: includes/free-shipping.php:79
     116#: includes/free-shipping.php:138
    117117msgid "You have free shipping!"
    118118msgstr ""
    119119
    120 #: includes/side-cart.php:89
     120#: includes/side-cart.php:101
    121121msgid "Your cart"
    122122msgstr ""
    123123
    124 #: includes/side-cart.php:102
     124#: includes/side-cart.php:114
    125125msgid "Open the cart"
    126126msgstr ""
    127127
    128 #: includes/side-cart.php:110
    129 #: wooajaxcart.php:140
     128#: includes/side-cart.php:122
     129#: wooajaxcart.php:143
    130130msgid "Cart"
    131131msgstr ""
    132132
    133 #: includes/side-cart.php:113
     133#: includes/side-cart.php:125
    134134msgid "Close the cart"
    135135msgstr ""
    136136
    137 #: includes/side-cart.php:148
     137#: includes/side-cart.php:160
    138138msgid "Coupon code"
    139139msgstr ""
    140140
    141 #: includes/side-cart.php:149
     141#: includes/side-cart.php:161
    142142msgid "Apply"
    143143msgstr ""
    144144
    145 #: includes/side-cart.php:159
     145#: includes/side-cart.php:171
    146146msgid "Applied"
    147147msgstr ""
    148148
    149149#. translators: %s: the coupon code
    150 #: includes/side-cart.php:161
     150#: includes/side-cart.php:173
    151151#, php-format
    152152msgid "Remove the coupon %s"
    … …  
    154154
    155155#. translators: %s: the coupon code
    156 #: includes/side-cart.php:161
     156#: includes/side-cart.php:173
    157157msgid "Remove"
    158158msgstr ""
    159159
    160 #: includes/side-cart.php:165
     160#: includes/side-cart.php:177
    161161msgid "After discounts"
    162162msgstr ""
    163163
    164 #: includes/side-cart.php:211
     164#: includes/side-cart.php:223
    165165msgid "The coupon could not be applied. Please reload the page and try again."
    166166msgstr ""
    167167
    168 #: templates/wac-qty-select.php:26
     168#. translators: %s: the product's name.
     169#: templates/wac-qty-select.php:33
     170#, php-format
     171msgid "%s quantity"
     172msgstr ""
     173
     174#. translators: %s: the product's name.
     175#: templates/wac-qty-select.php:33
     176msgid "Quantity"
     177msgstr ""
     178
     179#: templates/wac-qty-select.php:51
    169180msgctxt "Product quantity input tooltip"
    170181msgid "Qty"
    171182msgstr ""
    172183
    173 #: wooajaxcart.php:65
     184#: wooajaxcart.php:68
    174185msgid "Display -/+ buttons around product quantity input"
    175186msgstr ""
    176187
    177 #: wooajaxcart.php:66
    178 #: wooajaxcart.php:72
    179 #: wooajaxcart.php:78
    180 #: wooajaxcart.php:87
    181 #: wooajaxcart.php:192
     188#: wooajaxcart.php:69
     189#: wooajaxcart.php:75
     190#: wooajaxcart.php:81
     191#: wooajaxcart.php:90
     192#: wooajaxcart.php:195
    182193msgid "General"
    183194msgstr ""
    184195
    185 #: wooajaxcart.php:71
     196#: wooajaxcart.php:74
    186197msgid "Show item quantity as select instead numeric field"
    187198msgstr ""
    188199
    189 #: wooajaxcart.php:77
     200#: wooajaxcart.php:80
    190201msgid "Items to show on select"
    191202msgstr ""
    192203
    193 #: wooajaxcart.php:86
     204#: wooajaxcart.php:89
    194205msgid "Show user confirmation when change item quantity to zero or empty"
    195206msgstr ""
    196207
    197 #: wooajaxcart.php:92
     208#: wooajaxcart.php:95
    198209msgid "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"
    199210msgstr ""
    200211
    201 #: wooajaxcart.php:93
    202 #: wooajaxcart.php:99
    203 #: wooajaxcart.php:106
    204 #: wooajaxcart.php:113
    205 #: wooajaxcart.php:120
    206 #: wooajaxcart.php:130
    207 #: wooajaxcart.php:136
    208 #: wooajaxcart.php:148
    209 #: wooajaxcart.php:158
    210 #: wooajaxcart.php:165
    211 #: wooajaxcart.php:172
     212#: 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
    212223msgid "Side cart"
    213224msgstr ""
    214225
    215 #: wooajaxcart.php:98
     226#: wooajaxcart.php:101
    216227msgid "Open the side cart when a product is added to the cart"
    217228msgstr ""
    218229
    219 #: wooajaxcart.php:105
     230#: wooajaxcart.php:108
    220231msgid "Show a floating cart button with the item count"
    221232msgstr ""
    222233
    223 #: wooajaxcart.php:112
     234#: wooajaxcart.php:115
    224235msgid "Show a coupon form in the side cart (when coupons are enabled in WooCommerce)"
    225236msgstr ""
    226237
    227 #: wooajaxcart.php:119
     238#: wooajaxcart.php:122
    228239msgid "Side cart style: a drawer that slides in from the side, or a popup in the middle of the screen"
    229240msgstr ""
    230241
    231 #: wooajaxcart.php:124
     242#: wooajaxcart.php:127
    232243msgid "Drawer"
    233244msgstr ""
    234245
    235 #: wooajaxcart.php:125
     246#: wooajaxcart.php:128
    236247msgid "Popup"
    237248msgstr ""
    238249
    239 #: wooajaxcart.php:129
     250#: wooajaxcart.php:132
    240251msgid "Accent colour (floating button, checkout button, progress bar) — empty: the default colours"
    241252msgstr ""
    242253
    243 #: wooajaxcart.php:135
     254#: wooajaxcart.php:138
    244255msgid "Floating button icon"
    245256msgstr ""
    246257
    247 #: wooajaxcart.php:141
     258#: wooajaxcart.php:144
    248259msgid "Cart (outline)"
    249260msgstr ""
    250261
    251 #: wooajaxcart.php:142
     262#: wooajaxcart.php:145
    252263msgid "Shopping bag"
    253264msgstr ""
    254265
    255 #: wooajaxcart.php:143
     266#: wooajaxcart.php:146
    256267msgid "Basket"
    257268msgstr ""
    258269
    259 #: wooajaxcart.php:147
     270#: wooajaxcart.php:150
    260271msgid "Floating button position"
    261272msgstr ""
    262273
    263 #: wooajaxcart.php:152
     274#: wooajaxcart.php:155
    264275msgid "Bottom right"
    265276msgstr ""
    266277
    267 #: wooajaxcart.php:153
     278#: wooajaxcart.php:156
    268279msgid "Bottom left"
    269280msgstr ""
    270281
    271 #: wooajaxcart.php:157
     282#: wooajaxcart.php:160
    272283msgid "Side cart title (empty: \"Your cart\")"
    273284msgstr ""
    274285
    275 #: wooajaxcart.php:164
     286#: wooajaxcart.php:167
    276287msgid "Checkout button text (empty: WooCommerce's \"Checkout\")"
    277288msgstr ""
    278289
    279 #: wooajaxcart.php:171
     290#: wooajaxcart.php:174
    280291msgid "Empty cart text (empty: WooCommerce's \"No products in the cart.\")"
    281292msgstr ""
    282293
    283 #: wooajaxcart.php:178
     294#: wooajaxcart.php:181
    284295msgid "Show a free shipping progress bar in the side cart, Mini-Cart, Cart page and Cart block"
    285296msgstr ""
    286297
    287 #: wooajaxcart.php:179
    288 #: wooajaxcart.php:185
     298#: wooajaxcart.php:182
     299#: wooajaxcart.php:188
    289300msgid "Free shipping bar"
    290301msgstr ""
    291302
    292 #: wooajaxcart.php:184
     303#: wooajaxcart.php:187
    293304msgid "Order amount for free shipping (empty: read from the free shipping method of the shopper's shipping zone)"
    294305msgstr ""
    295306
    296 #: wooajaxcart.php:191
     307#: wooajaxcart.php:194
    297308msgid "AJAX timeout in milliseconds to refresh the cart on change"
    298309msgstr ""
    299310
    300 #: wooajaxcart.php:251
    301 #: wooajaxcart.php:261
     311#: wooajaxcart.php:254
     312#: wooajaxcart.php:264
    302313msgid "Are you sure you want to remove this item from cart?"
    303314msgstr ""
    304315
    305 #: wooajaxcart.php:260
     316#: wooajaxcart.php:263
    306317msgid "Updating..."
    307318msgstr ""
  • woocommerce-ajax-cart/trunk/includes/free-shipping.php

    r3780066 r3782015  
    1818function wac_free_shipping_threshold() {
    1919    $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
     38function wac_free_shipping_zone_minimum() {
    2339    if ( !function_exists('WC') || !WC()->cart || !class_exists('WC_Shipping_Zones') ) {
    2440        return 0;
    … …  
    105121    $base = plugin_basename(WAC_BASE_FILE);
    106122
    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.
    108125    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);
    109127    if ( wac_option('free_shipping_bar') == 'yes' ) {
    110128        wp_enqueue_style('wac-free-shipping');
    … …  
    112130
    113131    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);
    115133        wp_localize_script('wac-free-shipping-block', 'wac_free_shipping', array(
    116134            'threshold' => wac_free_shipping_threshold(),
  • woocommerce-ajax-cart/trunk/includes/side-cart.php

    r3780066 r3782015  
    1313// 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
    1414function 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);
    1628}
    1729
  • woocommerce-ajax-cart/trunk/readme.txt

    r3780066 r3782015  
    44Requires at least: 5.0
    55Tested up to: 7.1
    6 Stable tag: 1.5.1
     6Stable tag: 1.5.2
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    61613. Done. This plugin no requires extra configurations to work
    6262
     63== Frequently Asked Questions ==
     64
     65= Can a developer change what the plugin does? =
     66
     67Yes, 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
    6381== Screenshots ==
    6482
    … …  
    7088
    7189== 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)
    7297
    7398= 1.5.1 =
  • woocommerce-ajax-cart/trunk/templates/wac-qty-select.php

    r3780066 r3782015  
    11<?php
    22/**
    3  * Cart Page
     3 * Product quantity inputs, as a dropdown
    44 *
    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.
    610 *
    711 * HOWEVER, on occasion WooCommerce will need to update template files and you
    … …  
    1115 * the readme will list any important changes.
    1216 *
    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.
    1623 */
    1724
    1825defined( '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' );
    2334?>
    2435<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; ?>
    4369</div>
     70<?php
     71// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
  • woocommerce-ajax-cart/trunk/wooajaxcart.php

    r3780066 r3782015  
    44Plugin URI: https://wordpress.org/plugins/woocommerce-ajax-cart/
    55Description: Updates the WooCommerce cart with AJAX as soon as a quantity changes — no "Update cart" click needed
    6 Version: 1.5.1
     6Version: 1.5.2
    77Author: Moises Heberle
    88Author URI: https://mhtec.org/contact/
    … …  
    3535        if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
    3636            \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 );
    3740        }
    3841    } );
    … …  
    285288        $input = str_replace(array('<div class="quantity">', '</div>'), array('', ''), $inputDiv);
    286289        $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    }
    291304   
    292305    // 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
    … …  
    296309        $html .= '</a>';
    297310
    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);
    300324    }
    301325   
Note: See TracChangeset for help on using the changeset viewer.