Multi-Product Buy Form

Top  Previous  Next

To add more than one product to the cart with one button, call the multiproductbuy.php script with a form post. An example of the form code is included with the AShop V distribution package in the file named multiproductEXAMPLE.html.

 

clip0210166

clip0210167

 

Here is the example code. Change the products value to match the actual productid numbers or each product as listed in the admin panel under Edit Catalog. The returnurl value is where the Continue Shopping button returns to. If not set, the Continue Shopping button will return to catalogue.php. This URL can be set to return to the same order page or to another page of ordering options. It may be set as a relative URL (multiproductEXAMPLE.html) or an absolute URL (http://yoursite.com/ashop/multiproductEXAMPLE.html).

 

<form action="multiproductbuy.php" method="post">

 <p>

   <input name="products[]" type="checkbox" id="products" value="126">

   Product 126</p>

 <p>

   <input name="products[]" type="checkbox" id="products" value="111">

   Product 111</p>

 <p>

   <input name="products[]" type="checkbox" id="products" value="115">

   Product 115</p>

 <p>

   <input type="submit" name="Submit" value="Add to cart">

   <input name="returnurl" type="hidden" id="returnurl" value="multiproductEXAMPLE.html">

   <input name="action" type="hidden" id="action" value="basket">

   <br>

 </p>

</form>

 

Change the productid numbers to match the actual products. Add options for more or less products. The checkboxes can be initially checked or unchecked. Fields can be hidden to include groups of products in multiple forms on the page. The HTML forms are editable using an HTML editor program such as DreamWeaver or FrontPage.

 

Here is an example where the same three products added from hidden fields.

 

clip0210168

 

<form action="multiproductbuy.php" method="post">

 <p>

   <input name="products[]" type="hidden" id="products" value="126"><input name="products[]" type="hidden" id="products" value="111"><input name="products[]" type="hidden" id="products" value="115">

   Description of the multi-product.

 </p>

 <p>

   <input type="submit" name="Submit" value="Buy All Three Products">

   <input name="returnurl" type="hidden" id="returnurl" value="multiproductEXAMPLE.html">

   <input name="action" type="hidden" id="action" value="basket">

   <br>

 </p>

</form>