Page 1 of 1

How to refresh product quantity input field after Add to cart?

Posted: Tue Aug 06, 2019 4:39 pm
by cepcemuh
Hello guys,
I would like to ask for little help... I have some product with radio options and I would like when the customer choose the radio option, set the quantity in the input field and finally click on add to cart button, the input field to be nulled (refreshed) to 1 as default. On this way the user will be able to select another radio option and set new quantity. At the moment, the user is able to add in cart 5 items from Option 1 but if they wanna add several items from Option 2, I would like after they select and add to cart 5 from Option one, the input field to be refreshed to 1 again. And for each option... Is there a way? If I have not explained good, let's ask in short... Product A is with 5 options. The user select Option 1, make the quantity and after Add to cart button is clicked, I need the input quantity filed to be refreshed with 1 again as default. Thank you.

Re: How to refresh product quantity input field after Add to cart?

Posted: Tue Aug 06, 2019 5:06 pm
by DigitCart
Hi
If I understand you correctly, please edit this file:
catalog\view\theme\{your-theme}\template\product\product.twig

Find:

Code: Select all

$('#cart > button')
Add before it:
$('#input-quantity').val(1);

And clear the theme cache if it is enabled, you may need to refresh the modifications too.

Re: How to refresh product quantity input field after Add to cart?

Posted: Tue Aug 06, 2019 5:47 pm
by cepcemuh
Many thanks for your fast response but unfortunately I do not have such a line but this one:

Code: Select all

<input type="button" value="<?php echo $button_cart; ?>" id="button-cart" rel="<?php echo $product_id; ?>" data-loading-text="<?php echo $text_loading; ?>" class="button" />
And several lines below, I have this block:

Code: Select all

$('#cart_block #cart_content').load('index.php?route=common/cart/info #cart_content_ajax');
				$('#cart_block #total_price_ajax').load('index.php?route=common/cart/info #total_price');
				$('#cart_block #total_item_ajax').load('index.php?route=common/cart/info #total_item');

Re: How to refresh product quantity input field after Add to cart?

Posted: Tue Aug 06, 2019 5:51 pm
by DigitCart
Hi
You are using a custom theme, add it before:
$('#cart_block #cart_content').load

if it does not work, please share a link to your product page.

Re: How to refresh product quantity input field after Add to cart?

Posted: Tue Aug 06, 2019 5:56 pm
by cepcemuh
It doesn't work... I use this theme and my settings are the same as here... Thank you for taking a look:
http://ninethemes.net/epro/opencart/2/i ... duct_id=31

Re: How to refresh product quantity input field after Add to cart?

Posted: Tue Aug 06, 2019 6:00 pm
by DigitCart
I do not see the new code in your page source, please clear the theme cache and refresh the modifications.

Re: How to refresh product quantity input field after Add to cart?

Posted: Tue Aug 06, 2019 6:07 pm
by cepcemuh
Oh, sorry, I showed you the template but not my page... here you can see my product page with your code inside... I cleared the cache...
https://divage.steliyan.com/index.php?r ... duct_id=75

Re: How to refresh product quantity input field after Add to cart?

Posted: Tue Aug 06, 2019 6:10 pm
by DigitCart
use this:
$('#quantity_wanted').val(1);

Re: How to refresh product quantity input field after Add to cart?

Posted: Tue Aug 06, 2019 6:25 pm
by cepcemuh
Wow... you're awesome... Thanks a lot! It works!!!

Re: How to refresh product quantity input field after Add to cart?

Posted: Tue Aug 06, 2019 6:46 pm
by DigitCart
You are welcome.

Re: How to refresh product quantity input field after Add to cart?

Posted: Thu Feb 18, 2021 1:34 am
by muratcix11
I have Same problem. im using Claue - The Clean & Minimalist OpenCart Theme but i cant fixed. can you help me pls