Remove 'Add To My Cart' button if item already selected
Posted: Mon Jul 15, 2013 2:02 am
Hi, I am setting up a cart based on Calguys tutorial located at: http://calguy1000.com/Blogs/8/60/cmsms- ... ow-to.html using the Products, Cart and Orders modules.
We have products we give away free but you are only allowed to order one of each free item. I have removed the Quantity field from the Cart-AddToCart template but if you keep pressing the Add To My Cart button it will keep adding an additional item per click.
The Add To My Cart template is called from the Products Details template using:The Add To Cart Template looks like this:
The templates are pretty much unchanged from the original ones while I am testing.
What I would like to do is once someone adds one of the free items to their cart then the button is removed and a message stating the item has already been selected appear.
I have tried adding an in the add to cart code but I am unsure what the variable is for me to access the quantity of the product. Usually I can work this stuff out (I am by no means a PHP programmer but CMSMS has made it easier for me to work this stuff out in the past) unfortunately, this time I am stumped.
If you would like to see what I am up to you can visit:
http://103.18.108.3/~peogovau/index.php ... eturnid=61
The button is at the bottom of the page, once clicked it will take you to the cart page.
Please let me know if you need any more information or if I have posted in the wrong place, can't wait to learn what the solution is.
Thanks.
We have products we give away free but you are only allowed to order one of each free item. I have removed the Quantity field from the Cart-AddToCart template but if you keep pressing the Add To My Cart button it will keep adding an additional item per click.
The Add To My Cart template is called from the Products Details template using:
Code: Select all
{cgecomm_form_addtocart product=$entry->id}Code: Select all
{* add to cart template *}
{if isset($cart_error)}
{cgerror}{$cart_error}{/cgerror}
{/if}
{$formstart}
{if isset($attribute_count) && $attribute_count gt 0}
{foreach from=$attributes item='attrib'}
{$attrib->name}: {$attrib->control}
{/foreach}
{/if}
<input type="submit" name="{$submitname}" value="{$addtocarttext}"/>
{$formend}What I would like to do is once someone adds one of the free items to their cart then the button is removed and a message stating the item has already been selected appear.
I have tried adding an
Code: Select all
{if $var > 0}DO THIS{/if}If you would like to see what I am up to you can visit:
http://103.18.108.3/~peogovau/index.php ... eturnid=61
The button is at the bottom of the page, once clicked it will take you to the cart page.
Please let me know if you need any more information or if I have posted in the wrong place, can't wait to learn what the solution is.
Thanks.