| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Checking if Product is already in cart | |||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() I would like to offer customers the option to purchase another product when they go to check out. I know there are some custom mods that do that, but my needs are simple and only needed for a few products.
I have it working as far as offering the "cross sell" product, but I only want to offer it if it's not already in the cart, which I can't figure out how to get working. At the top of cart.tpl, I was trying to loop through the cart contents and set a variable to flag the 2nd if-then to not offer the "Widget" if it's already in the cart. Here's what I have, but that part isn't working: The first loop searches if Widget (productid 16864) is in the cart and flags (or should flag) a variable if it's found. The second part checks if product 16236 (a nice compliment to Widget/16236) and offers Widget if 16864 is being purchased: {section name=product loop=$products} {if $products[product].productid eq 16864} $smarty->assign('Widget', 'true'); {/if} {/section} {section name=product loop=$products} {if $products[product].productid eq 16236 && $Widget ne 'true'} <table width="100%" border="0" cellpadding="13" cellspacing="0" bgcolor="#EEEEEE"> <tr> <td> <div align="center"> <span style="color: #990000; font-size: 14pt;">*** SPECIAL OFFER ***</span><br> <span style="color: #000033; font-size: 10pt;">Purchase the <i>Demo Test Widget Addon #1 Gadget</i> today and receive 25% off your entire purchase!</span> <br /> <br /> <a href="{$xcart_web_dir}/cart.php?mode=add&productid=16864&amount=1"><img src="/images/YesPlease.png" width="118" height="48" alt="Yes Please"></a> </div> </td> </tr> </table> {/if} {/section} ________________________ I'm sure it's something simple I'm missing. I just don't have enought experience with php or smarty to see what I'm doing wrong. Thanks. - JRC
__________________
X-Cart Pro 4.1.12 | Linux | MySQL |
|||||||
#2
|
|||||||||
|
|||||||||
![]() Try replacing
Code:
Code:
__________________
Regards, Piotr Markushin X-Cart PDF Catalog Generator NEW Professional X-Cart Skins Store (7 new skins added in August 2008!) ahedOffice.com - Web 2.0 Online Groupware |
|||||||||
#3
|
|||||||
|
|||||||
![]() Thanks, that worked.
__________________
X-Cart Pro 4.1.12 | Linux | MySQL |
|||||||
|
|||
X-Cart forums © 2001-2020
|