| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Cart modification: how to hide option if product already in cart? | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Cart modification: how to hide option if product already in cart?
I've created a snippet of code to add a giftwrap option to the shopping cart (a hidden product, click to opt-in).
However, I want this NOT to show up if there is already giftwrap in the cart. Obviously the basic structure I'm after is something like: {if [cart contents] [does not contain] [product 3491]} {include file="customer/main/gift_wrap.tpl"} {/if} but I'm not sure what variables to use in the if statement, or indeed, what expression Smarty uses for a "does not contain" match (so far I've just seen equals, not equals, greater than, less than etc. etc.) Can anyone advise here? Many thanks, Rachael
__________________
-- X-cart Version 4.1.9 |
|||||||
#2
|
|||||||
|
|||||||
Re: Cart modification: how to hide option if product already in cart?
Still hoping that someone out there has the answer to this... There must be some of this logic used somewhere in X-Cart because of the "give products for free" if a certain product is added to the card special-offers thing.
Cheers, Rachael
__________________
-- X-cart Version 4.1.9 |
|||||||
#3
|
|||||||
|
|||||||
Re: Cart modification: how to hide option if product already in cart?
If you want the include after the list of products you can check in the loop that lists the products. Change this:
Code:
Code:
Then after the {/section} wherever you want it add: Code:
If you want it before the list of products you'll probably have to add a second {section} {/section} block to loop through the array just to check for it.
__________________
Manuka Bay Company X-Cart Version 4.0.19 [Linux] UGG Boots and other fine sheepskin products http://www.snowriver.com |
|||||||
#4
|
|||||||
|
|||||||
Re: Cart modification: how to hide option if product already in cart?
Hi Ralph,
Thanks so much - that works beautifully. This is a very elementary question, but I am really new to this: Why does the check need to be assigned to a separate variable for the evaluation to work? Previously, I had: Code:
but although it was including the file fine, it was doing it regardless of the existence of product 3491. Though I guess that could be (a) the double quotes round the product ID (b) the fact that I had the evaluation happening outside the products section?? It would be useful to know why this works for future ref... Cheers, Rachael
__________________
-- X-cart Version 4.1.9 |
|||||||
#5
|
|||||||
|
|||||||
Re: Cart modification: how to hide option if product already in cart?
Quote:
__________________
Manuka Bay Company X-Cart Version 4.0.19 [Linux] UGG Boots and other fine sheepskin products http://www.snowriver.com |
|||||||
|
|||
X-Cart forums © 2001-2020
|