Suppressing Cart Display When Adding an Item

Don't want to view the cart display each time an item is added to the shopping cart? Here's an example of how to do it. It uses JavaScript, and has provision for older browsers and browsers with JavaScript turned off. In those cases it performs in the regular "tried & true" manner.


Widget A. This widget is the finest that money can buy.

Image

qty:
<table border="1" cellspacing="0" cellpadding="5">
<tr>
<td>
<img src="widgeta.gif" alt="Image" />
</td>
<td bgcolor="#F2F2F2">
<form action="http://www.cartserver.com/sc/cart.cgi" method="post">
<input type="hidden" name="item" value="s-8882^widgeta^Widget A^19.95^op5^^^^1.2^http://www.americart.com/sc/widgeta.gif" />
<input type="hidden" name="op1" value="&lt;br&gt;Size " />
<input type="hidden" name="op3" value="&lt;br&gt;Finish " />
<!-- just did the two above to make the cart display fancier -->
<select name="op2">
<option selected="selected"> Tiny </option>
<option> Small </option>
<option> Medium </option>
<option> Large </option>
<option> Huge </option>
</select>
<select name="op4">
<option selected="selected"> Gold </option>
<option> Silver </option>
</select>
<br />
<table border="0" align="center">
<tr>
<td> qty:
<input type="text" name="op5" value="1" size="2" />
</td>
<td align="right">

<input type="image" src="/images/addtocart.gif" name="nvadd" />
<!-- the only thing special to make it not do a view is name=nvadd instead of name=add -->

</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<table>
<tr>
<td>
<form action="http://www.cartserver.com/sc/cart.cgi" method="post">
<input type="hidden" name="item" value="s-8882" />
<input align="middle" type="image" border="0" name="checkout" src="/images/checkout.gif" />
</form>
</td>
<td>
<form action="http://www.cartserver.com/sc/cart.cgi" method="post">
<input type="hidden" name="item" value="s-8882" />
<input type="image" border="0" name="view" src="/images/viewcart.gif" />
</form>
</td>
</tr>
</table>
Note 1: The only thing special to make it not do a view is name=nvadd instead of name=add in the add to cart button tag.

Note 2: If your shipping setup is such that the shipping method selection page comes up when people view the cart the first time, be sure that the "goto checkout" buttons on your site use name=view instead of name=checkout. This will invoke the cart display at least once before checking out, which is necessary.

This means that the "view" and "checkout" buttons on your site will do the same thing, but that is acceptable since the shopper isn't seeing the cart display when adding items.

Copyright. All rights reserved. Americart - 2011