Skip to main content
Question

Quantity and Add to Cart variables


Hi. I’m prototyping a select color, quantity and add to cart prototype and am having trouble with the variables.

The quantity is working fine, with:
Set variable [#itemcount] to [#itemcount] + 1

And on the ‘Add to Cart’ button I have:
To make visible any added item on the cart page
if [#ItemCount] > 0 Set variable [AddedToCart] to true

And to count the number of items added to the cart
Set variable [#CartCount] to [#itemcount: Black] + [#itemcount: Chrome] + etc

  • Where Black and Chrome etc are variable modes

The problem is that the CartCount is adding any quantity that is selected but I want it to only add the quantity after clicking Add to Cart eg. If I select ‘Black’ quantity 2 but don’t click Add to Cart, then select ‘Chrome’ and select quantity 2 and Add to Cart, the cart counter will show 4 and not 2.

I thinking I need some statement that says ‘only add quantity if Add to Cart is clicked’ but I can’t figure it out with variables.

Thanks for your help.

This topic has been closed for replies.

2 replies

Philipp_Wartenberg1

I assume you need to reset your variable #CartCount to 0, when changing the colour. you could do this by providing an else action. But I’m not sure, since I can’t see all of your variables and conditions.


Thanks @Philipp_Wartenberg1 the colours are setup in a component with the interaction swopping the component and changing the colour mode, so I could reset the #CartCount there. Then I’d need to make an exception to the reset for any colours that have been added to cart?


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings