CART PAGE INPUT QUANTITY CHANGE AUTO UPDATE PRICE BASED ON QTY

Highlighted
Excursionist
31 0 5

Hi,

I am trying to make the shopify ajax api works so when customer add products in cart, then when changed his mind and try to increase/decrease number of product, he/she don't need to click "UPDATE" button.

I know this is possible but i can't make it work.

Highlighted
Explorer
83 0 28

Hi,

You can try triggering the button click with jquery when the input field is updated. The code below is assuming that the input has the class of "qty-input" and your button has the id of "cart_update". You may need to change those depending on what your classes/id's are for those elements.

$('.qty-input').on('input', function() {
	$( "#cart_update" ).trigger( "click" );
});

 

Highlighted
Excursionist
31 0 5

THANK YOU SO MUCH!!!!

0 Likes
Highlighted
New Member
1 0 0

Thank you so much. Working like a charm!

0 Likes
Highlighted
Tourist
9 0 2

Guys, I'm a noob at coding. How can we make this work for Brooklyn theme?

0 Likes
Highlighted
New Member
1 0 0

where to find this file?

0 Likes
Highlighted
Tourist
3 0 2

This is an older post, but if you're still looking for an answer, you need to adjust the class names for this to work in the Brooklyn theme. Try pasting the following to the bottom of cart.liquid:

<script>
  $('.cart__product-qty').on('input', function() {
      $( ".update-cart" ).trigger( "click" );
  });
</script>

This essentially renders the "Update Cart" button unnecessary for your users, so you may wish to add "style="display: none" to the update button. Hope that helps!

Highlighted
New Member
1 0 0

Hi guys!

What would be the code snippet for the Flow theme? I have tried my best buy could not figure it out.

Thanks in advance for the help!

Ratchanee

0 Likes