Post by cepcemuh » Tue Aug 06, 2019 4:39 pm

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.

New member

Posts

Joined
Sat Jan 21, 2017 5:15 pm

Post by DigitCart » Tue Aug 06, 2019 5:06 pm

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.

My Extensions


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by cepcemuh » Tue Aug 06, 2019 5:47 pm

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');

New member

Posts

Joined
Sat Jan 21, 2017 5:15 pm

Post by DigitCart » Tue Aug 06, 2019 5:51 pm

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.

My Extensions


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by cepcemuh » Tue Aug 06, 2019 5:56 pm

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

New member

Posts

Joined
Sat Jan 21, 2017 5:15 pm

Post by DigitCart » Tue Aug 06, 2019 6:00 pm

I do not see the new code in your page source, please clear the theme cache and refresh the modifications.

My Extensions


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by cepcemuh » Tue Aug 06, 2019 6:07 pm

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

New member

Posts

Joined
Sat Jan 21, 2017 5:15 pm

Post by DigitCart » Tue Aug 06, 2019 6:10 pm

use this:
$('#quantity_wanted').val(1);

My Extensions


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by cepcemuh » Tue Aug 06, 2019 6:25 pm

Wow... you're awesome... Thanks a lot! It works!!!

New member

Posts

Joined
Sat Jan 21, 2017 5:15 pm

Post by DigitCart » Tue Aug 06, 2019 6:46 pm

You are welcome.

My Extensions


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by muratcix11 » Thu Feb 18, 2021 1:34 am

I have Same problem. im using Claue - The Clean & Minimalist OpenCart Theme but i cant fixed. can you help me pls

Newbie

Posts

Joined
Thu Feb 18, 2021 1:31 am
Who is online

Users browsing this forum: No registered users and 410 guests