• Resolved christian70

    (@christian70)


    The plugin works like a charm. Next step: I’d like to remove the ‘update cart’ button, so I wonder if there’s a way to make the cart easily update via Ajax when I click on +-. I tried with the classic ‘trigger update_cart’ Jquery function but it does not work (unless I click on +- twice, because at the first click the value of input number field don’t change in input field, even if the displayed value has changed). So the trigger function cannot hook the ‘value’s change’ event…

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Saiful Islam

    (@codersaiful)

    Use following Hook. it will work for any site.
    Thanks

    
    <?php
    add_action( 'wp_footer',function(){
    ?>
    <script>
        jQuery( document ).ready(function($) {
            let updateButton = $('body.woocommerce-cart.woocommerce-page.woocommerce-js td.actions button.button[name="update_cart"]');
            $(document.body).on('change','input.wqpmb_input_text.input-text.qty.text',function(){
                
                setTimeout(function(){
                    updateButton.trigger('click');
                },700);
            });
        });
    </script>
    <?php
    } );
    
    • This reply was modified 3 years ago by Saiful Islam. Reason: tab index fix from code
    • This reply was modified 3 years ago by Saiful Islam. Reason: tab index fix from code

    Hello!

    When i insert this script, it works, but only one time.

    When i click (+) or (-) it only update one time. When i click more than once, it will not update the cart.

    Plugin Author Saiful Islam

    (@codersaiful)

    Dear @tailordesigns
    Use following code. Actually on previous code, there was a little mistake.

    add_action( 'wp_footer',function(){
       ?>
       <script>
           jQuery( document ).ready(function($) {
    
               $(document.body).on('change','input.wqpmb_input_text.input-text.qty.text',function(){
                let updateButton = $('button.button[name="update_cart"]');
                   setTimeout(function(){
                       updateButton.trigger('click');
                   },700);
               });
           });
       </script>
       <?php
       } );

    Works perfect! Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Ajax auto update’ is closed to new replies.