FPHPSC AddItems
From FreeBert Wiki
Adding items to the shopping cart (Add To Cart Buttons)
You can place HTML code on any type of webpage (HTML, HTM, ASP, PHP, etc) to add items to the shopping cart for your customers to buy. You can add single items, one at a time, or multiple/batch items to your cart.
a) Adding Single Items - To add a single item to your cart; use a form like the one below:
<form method="post" action="http://www.mydomain.com/FPHPSC/ShoppingCart.php"> <input name="Title" type="hidden" value="My Item Title" /> <input name="SerialNum" type="hidden" value="SN55TEST" /> <input name="Price" type="hidden" value="9.99" /> <input name="Shipping1" type="hidden" value="1.99" /> <input name="Shipping2" type="hidden" value=".99" /> <input name="cmd" type="hidden" id="cmd" value="1" /> <input type="submit" name="Submit" value="Submit" /> </form>
Tips:
- all fields are mandatory, be sure to enter something into all the value fields
- make sure the action = the full URL to the ShippingCart.php file located on your server
- make sure the method = "post", NOT "get".
- make sure cmd = 1 for adding single item only
- Shipping 1 refers to the shipping for quantity = 1 of that item
- Shipping 2 refers to additional shipping amount for each quantity over 1
b) Adding Multiple Items - To add multiple items to your cart with the click of 1 button, use a form like the one below:
<form method="post" action="http://www.mydomain.com/FPHPSC/ShoppingCart.php"> <input name="Title0" type="hidden" value="My First Item Title" /> <input name="SerialNum0" type="hidden" value="SN55TEST1" /> <input name="Price0" type="hidden" value="9.99" /> <input name="Shipping10" type="hidden" value="1.99" /> <input name="Shipping20" type="hidden" value=".99" /> <input name="checkbox0" type="hidden" value="1" /> <input name="Title1" type="hidden" value="My Second Item Title" /> <input name="SerialNum1" type="hidden" value="SN55TEST2" /> <input name="Price1" type="hidden" value="19.99" /> <input name="Shipping11" type="hidden" value="2.99" /> <input name="Shipping21" type="hidden" value="1.99" /> <input name="checkbox1" type="hidden" value="0" /> <input name="Title2" type="hidden" value="My Third Item Title" /> <input name="SerialNum2" type="hidden" value="SN55TEST3" /> <input name="Price2" type="hidden" value="29.99" /> <input name="Shipping12" type="hidden" value="3.99" /> <input name="Shipping22" type="hidden" value="2.99" /> <input name="checkbox2" type="hidden" value="1" /> <input name="Batch_Count" type="hidden" value="3" /> <input name="cmd" type="hidden" id="cmd" value="5" /> <input type="submit" name="Submit" value="Submit" /> </form>
Tips:
- all fields are mandatory, be sure to enter something into all the value fields
- make sure the action = the full URL to the ShippingCart.php file located on your server
- make sure the method = "post", NOT "get".
- make sure cmd = 5 for adding batch / multiple items only
- Shipping 1 refers to the shipping for quantity = 1 of that item
- Shipping 2 refers to additional shipping amount for each quantity over 1
- Make sure each field name ends with a number (starting at 0 for the first item) as in example above
- Make sure to include the field Batch_Count which lets the cart know how many items to process
- Make sure to include the field checkbox for each item - a value of 1 will add the item, a value of 0 will ignore / skip the item. This last field is useful if you want to display a number of products in a list on a page - your customers can use a checkbox form element to choose which items they want to add to the cart all at once. When the form is submitted to the cart, the cart will process all items in the list, and only add the items with a value of 1 for checkbox. Thus, in the example code above, although 3 items are being passed to the shopping cart's add batch function, only "My First Item Title" and "My Third Item Title" will be added to the cart.
