• Resolved cochii

    (@cochii)


    Hello
    I’m trying to install the last update of woocommerce in local before to push in prod. I have the last version of wordpress. I use Astra Theme (with pro extension).
    When I go to the product list page and use the + and – buttons to change the quantity, when I click on the ‘Add to cart’ button, it always adds 1 quantity (even if I clicked 3 times on the + button). I found the solution by adding
    r['quantity'] = a.parent().find(o('.input-text.qty.text')).val()
    just before
    o(document.body) .trigger("adding_to_cart", [a, r]), t.data.addToCartHandler.addRequest

    do you know the problem? how can i fix it without having any impact with the next update

Viewing 2 replies - 1 through 2 (of 2 total)
  • @cochii – this isn’t something I’ve seen reported, so I’m inclined to believe this could be either a plugin or theme conflict.

    The best way to determine this is to:

    • Temporarily switch your theme to Storefront
    • Disable all plugins except for WooCommerce
    • Repeat the action that is causing the problem

    If you’re not seeing the same problem after completing the conflict test, then you know the problem was with the plugins and/or theme you deactivated. To figure out which plugin is causing the problem, reactivate your other plugins one by one, testing after each, until you find the one causing conflict. You can find a more detailed explanation on how to do a conflict test here.

    – Joey

    Thread Starter cochii

    (@cochii)

    Hi,
    I found a solution
    I add this code in functions.php

    function kia_print_quantity_footer_scripts() {
    
    if( did_action( 'woocommerce_after_shop_loop' ) ) {
    ?>
    <script type="text/javascript">
    jQuery( document ).ready(function($) {
    $('.product .qty').on('change', function() {
    $(this).closest( '.quantity' ).next( 'a' ).attr( 'data-quantity', $(this).val() );
    console.log( $(this).closest( '.quantity' ).next( 'a' ).attr('data-quantity') );
    });
    });
    </script>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add to cart wrong quantity’ is closed to new replies.