• hey there,

    I see several threads here that say the + and – in the shopping cart are doubling after the recent oceanwp update. However, my problem is that the + and – disappear as soon as you press the buttons and start updating the shopping cart. I’m using Elementor product templates.

    I already tried the cache solution but unfortunately it didn’t work. Is there any other solution or do I have to go back to the old version?

    Sincerely,
    Ray

Viewing 13 replies - 1 through 13 (of 13 total)
  • Same here,

    Did not read the code, but seems woo-quantity-buttons.js is not applied on ajax calls as was wooQuantityButtons.js…

    For now I think I’ll bind refresh button with cart page reload.

    Hello All,

    Thank you for your report,
    This is forwarded to the developer team, and it will be checked and fixed for the next updates.

    Temporary solution to fix that issue:
    Please put the CSS below in Customizing Environment > Custom CSS/JS > JS Code:
    https://docs.oceanwp.org/article/354-add-custom-css-and-js-to-your-website

    var $j = jQuery.noConflict();
    
    function oceanwpWooQuantityButtons(i) {
        var o, t;
        ($cart = $j(".woocommerce div.product form.cart")),
            (i = i || ".qty"),
            (o = $j("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").find(i)) &&
                "date" !== o.prop("type") &&
                "hidden" !== o.prop("type") &&
                (o.parent().addClass("buttons_added").prepend('<a href="javascript:void(0)" class="minus">-</a>'),
                o.after('<a href="javascript:void(0)" class="plus">+</a>'),
                $j("input" + i + ":not(.product-quantity input" + i + ")").each(function () {
                    var o = parseFloat($j(this).attr("min"));
                    o && 0 < o && parseFloat($j(this).val()) < o && $j(this).val(o);
                }),
                !$j("body").hasClass("single-product") ||
                    "on" != oceanwpLocalize.floating_bar ||
                    $cart.hasClass("grouped_form") ||
                    $cart.hasClass("cart_group") ||
                    (t = $j(".woocommerce form input[type=number].qty")).on("keyup", function () {
                        var o = $j(this).val();
                        t.val(o);
                    }),
                $j(".plus, .minus").unbind("click"),
                $j(".plus, .minus").on("click", function () {
                    var o =
                            !$j("body").hasClass("single-product") || "on" != oceanwpLocalize.floating_bar || $cart.hasClass("grouped_form") || $cart.hasClass("cart_group")
                                ? $j(this).closest(".quantity").find(i)
                                : $j(".plus, .minus").closest(".quantity").find(i),
                        t = parseFloat(o.val()),
                        e = parseFloat(o.attr("max")),
                        a = parseFloat(o.attr("min")),
                        s = o.attr("step");
                    (t && "" !== t && "NaN" !== t) || (t = 0),
                        ("" !== e && "NaN" !== e) || (e = ""),
                        ("" !== a && "NaN" !== a) || (a = 0),
                        ("any" !== s && "" !== s && void 0 !== s && "NaN" !== parseFloat(s)) || (s = 1),
                        $j(this).is(".plus") ? (e && (e == t || e < t) ? o.val(e) : o.val(t + parseFloat(s))) : a && (a == t || t < a) ? o.val(a) : 0 < t && o.val(t - parseFloat(s)),
                        o.trigger("change");
                }));
    }
    
    $j(document ).ajaxComplete(function () {
    	"use strict";
    	oceanwpWooQuantityButtons();
    });

    Note: if you have a cache plugin or server cache. You need to clear its cache contents or disable them.

    Best Regards

    Thanks for this piece of code, but this doesn’t do.
    Now buttons are duplicated at page load and quantity are doubled at page load or ajax load (i.e. car refresh), even if buttons do appear now at ajax reload. At the same time, this introduces a “quantity doubled” bug (somehow logical as there are two ++ and two — button at page load, binded with the same event.

    Feel free to continue using the staging site I provided you to work on this.

    Hope it helps.

    Hi @madmax4ever,

    Please use this JS code:

    var $j = jQuery.noConflict();
    
    function oceanwpWooQuantityButtons(i) {
        var o, t;
        ($cart = $j(".woocommerce div.product form.cart")),
            (i = i || ".qty"),
            (o = $j("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").find(i)) &&
                "date" !== o.prop("type") &&
                "hidden" !== o.prop("type") &&
                (o.parent().addClass("buttons_added").prepend('<a href="javascript:void(0)" class="minus">-</a>'),
                o.after('<a href="javascript:void(0)" class="plus">+</a>'),
                $j("input" + i + ":not(.product-quantity input" + i + ")").each(function () {
                    var o = parseFloat($j(this).attr("min"));
                    o && 0 < o && parseFloat($j(this).val()) < o && $j(this).val(o);
                }),
                !$j("body").hasClass("single-product") ||
                    "on" != oceanwpLocalize.floating_bar ||
                    $cart.hasClass("grouped_form") ||
                    $cart.hasClass("cart_group") ||
                    (t = $j(".woocommerce form input[type=number].qty")).on("keyup", function () {
                        var o = $j(this).val();
                        t.val(o);
                    }),
                $j(".plus, .minus").unbind("click"),
                $j(".plus, .minus").on("click", function () {
                    var o =
                            !$j("body").hasClass("single-product") || "on" != oceanwpLocalize.floating_bar || $cart.hasClass("grouped_form") || $cart.hasClass("cart_group")
                                ? $j(this).closest(".quantity").find(i)
                                : $j(".plus, .minus").closest(".quantity").find(i),
                        t = parseFloat(o.val()),
                        e = parseFloat(o.attr("max")),
                        a = parseFloat(o.attr("min")),
                        s = o.attr("step");
                    (t && "" !== t && "NaN" !== t) || (t = 0),
                        ("" !== e && "NaN" !== e) || (e = ""),
                        ("" !== a && "NaN" !== a) || (a = 0),
                        ("any" !== s && "" !== s && void 0 !== s && "NaN" !== parseFloat(s)) || (s = 1),
                        $j(this).is(".plus") ? (e && (e == t || e < t) ? o.val(e) : o.val(t + parseFloat(s))) : a && (a == t || t < a) ? o.val(a) : 0 < t && o.val(t - parseFloat(s)),
                        o.trigger("change");
                }));
    }
    
    ($j = jQuery.noConflict())(window).ajaxComplete(function ($) {
    	"use strict";
    	if( $j(".woocommerce div.product form.cart").find(".plus") ) {
    		console.log('true');
    		$j(window).ajaxComplete(function ($) {
    			"use strict";
    			console.log('ajax');
    			oceanwpWooQuantityButtons();
    		});
    	} else {
    		console.log('else');
    		oceanwpWooQuantityButtons();
    	}
    });

    Thank you,
    Best Regards

    As we’ve discussed directly, it is not the solution, as it creates and other bad behavior (all buttons seems OK, i.e. not duplicated, but after cart refresh, the step quantity is 2, so one click on + or – gives +2 or -2…).

    I know you’re working on it at OceanWP, so stay tune! ??

    Hello @madmax4ever,

    Thank you for your report. We are aware of the issue.

    The code will be fixed as a temporary solution(of course, in some other conditions, it has created a new issue). However, this is forwarded to the developer team, and it will be fixed/improved for the next updates.

    Best Regards

    I am having the same problem too!! Have you found a solution yet? The +/- sign disappears after I click “UPDATE CART” button.
    I went to OCEANWP’s demo site https://towel.oceanwp.org/ and try out the update button. The +/- sign also disappear on the demo. Is it by design?
    It’s very inconvenient for customers who want to change quantity again after updating the cart. Are there any fix for this issue?

    Thank you
    Anna

    Same here. Looking forward to a fix as soon as possible. Really annoying for UX, and no other quantity buttons plugin can override this bug.

    It seems today’s update has fixed the issue. ?? So far, I haven’t experienced this bug since 3.0.4.

    Hello All,

    Please use the latest version of OceanWP theme (and other plugins).
    We’ve fixed your issue on this ticket on the latest version of the theme(v3.0.4):
    https://docs.oceanwp.org/article/653-oceanwp-theme-changelog
    https://docs.oceanwp.org/article/677-oceanwp-theme-ocean-extensions-changelogs
    ?
    @nnlam Thank you for your report; We’ll update all new demos to the latest version.

    Thank you all for your waiting.

    Warm Regards

    Last release of Ocean Wp won’t fix the issue. Still there.

    So the buttons are still not displayed, and if add the code above the minimun step is 2 and not one as it should be. What a disaster this theme, first and last time I will use it.

    Thread Starter raykaassoufle

    (@raykaassoufle)

    Is the problem solved now?

    Can I update the theme withouth any problems now?

    Kind regards

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Quantity Buttons (+ _) dissapear after update cart’ is closed to new replies.