====== Adding a product to the cart from anywhere ====== It's easy to add a product to your ProductCart-powered shopping cart from any page (or even an email). ===== Using a link ===== The code is extremely simple and can be used anywhere you can use an HTML link. * First, log into the Control Panel (or visit the product details page) and note down the **product ID**. This is not the SKU (part number), but rather the ID of the product in the database. It's shown in the querystring (browser address field) when you load a product details page in both the storefront and the Control Panel. * Use the product ID in your link. For example, [[http://www.earlyimpact.com/eistore/productcart/pc/instPrd.asp?idproduct=431|here is a link]] that adds "ProductCart" to the shopping cart on our Early Impact software store. The code looks as follows: Add to Cart * Replace the URL to the **instPrd.asp** page with the one that applies to your store * Replace the number that follows **idproduct=** with the ID of the product that you are trying to add ===== Using a form ===== 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.
* Replace the URL in the form //action// with the one that applies to your store * Replace the number in the **idproduct=** hidden field with the ID of the product that you are trying to add * If you don't want to show a quantity, you can make that a hidden field too by changing the field type Here is how this basic form would look:
ProductCart shopping cart software
===== Adding multiple products to the cart ===== 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:
ProductCart
eBay Add-on
Note the following: * The hidden field pCnt (at the bottom) tells ProductCart how many items are in the form * You need to have, for each product in the form: * An **idProductN** field, where N is the integer for each product, starting with 1 for the first product * The value in that hidden field is the //product ID//, as described earlier in this article * The **QtyM** field name contains the product ID after the string "QtyM" * The **BTOTOTALN** hidden field (where N changes as for idProductN - see above) contains the product price Here is how this basic form would look on an HTML page:
ProductCart
eBay Add-on
===== Adding an Apparel Sub-Product to the cart ===== 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: * Go to the product details page in the storefront * Use the "Choose and add another" feature * Mouse over the 'Remove' icon: the status bar in your browser shows you the ID of the sub-product ===== Addressing issue with "Stay of Page" feature ===== 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.