It's easy to add a product to your ProductCart-powered shopping cart from any page (or even an email).
The code is extremely simple and can be used anywhere you can use an HTML link.
<a href="http://www.earlyimpact.com/eistore/productcart/pc/instPrd.asp?idproduct=431">Add to Cart</a>
You can do the same with a form, which also allows you to specify the quantity to be added to the cart. The form could reside on any page, static or dynamic.
<form name="myForm" method="post" action="http://www.earlyimpact.com/eistore/productcart/pc/instPrd.asp"> <input type="text" name="quantity" value="1" size="2" maxlength="2"> <input type="hidden" name="idproduct" value="431"> <input type="submit" name="Submit" value="Add to cart"> </form>
Here is how this basic form would look:
ProductCart has the ability to add multiple items to the cart at the same time (there is a category display setting that allows for this, as you know). Therefore, adding multiple products to the cart at the same time from another page can certainly be done, but it is a bit more difficult to do.
Here is the code associated with a form that can add to products to the shopping cart:
<form name="m" method="post" action="http://www.earlyimpact.com/eistore/productcart/pc/instPrd.asp" id="m"> <input name="idProduct1" type="hidden" value="431"> <input name="QtyM431" type="text" value="0" size="2" maxlength="10"> ProductCart <br /> <input name="BTOTOTAL1" type="hidden" value="695"> <input name="idProduct2" type="hidden" value="444"> <input name="QtyM444" type="text" value="0" size="2" maxlength="10"> eBay Add-on <br /> <input name="BTOTOTAL2" type="hidden" value="395"> <input type="hidden" name="pCnt" value="2"> <input type="submit" name="Submit" value="Add to cart"> </form>
Note the following:
Here is how this basic form would look on an HTML page:
For users of the Apparel Add-on: as you know, an Apparel product is made of a parent product and a series of “sub-products”. If you want to add a specific sub-product to the cart, you need tell ProductCart that what you are passing to the system is indeed the ID of a sub-product.
Here is a working example from one of our demo stores:
http://www.earlyimpact.com/demos/apparel/pc/instprd.asp?idproduct=1226&apparel=1
Note the parameter “apparel=1” in the string.
You can find out the ID of a sub-product by using this simple trick:
If you are adding a product to cart from another web site, such as a blog, or some other location, such as an email AND you are using the “stay on page” feature, you will need to make a slight modification to the file pc/atc_instprd.asp.
Immediately below these two lines near the top of the file:
originalurl = lcase(Request.ServerVariables("HTTP_REFERER"))
atc_idProduct = getuserinput(request("idproduct"),0)
… add the following lines:
If InStr(originalurl,scStoreURL) = 0 Then originalurl = scStoreURL & "/" & scPcFolder & "/pc/viewprd.asp?idproduct=" & atc_idproduct
originalurl=replace(originalurl,"//","/")
originalurl=replace(originalurl,"https:/","https://")
originalurl=replace(originalurl,"http:/","http://")
This will make sure that your post is not redirected back to the original, referring web site. In the event the product was added from an e-mail service such as GMail, it will keep the customer on your site instead of redirecting them back to the email service.