Order-Link Ordering Method
Previous  Top  Next


The Order-Link method supports the Add to Cart, View Cart, and Check Out functionality within HTML pages. The Order-Link pages can be located anywhere, even on remote servers. This is a simple method to add buy buttons, view cart and checkout links to html pages.

See also: Order-Link Tech Tip

Add to Cart Order-Link Form
When an Add to Cart link is clicked, the product is added to the cart and the shopping cart basket page opens with showing the product(s) and prices.

For each product Add to Cart button, add a form and set the product ID accordingly. The product ID is listed next to each product within the Administration Panel > Edit Products.

Here is an example. The required parameters are quantity, product, and add.

<form method="get" action="http://www.yourdomain.com/ashop/basket.php">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="product" value="1">
<input type="hidden" name="add" value="1">
<input type="submit" name="Submit" value="Add to Cart">
</form>

Note: When a form is inserted inside of a table cell, it can cause unwanted enlargement of the table cell and distort the intended page design. To avoid this problem, put the <form> and </form> tags between the <tr><td> and the </tr></td> tags.
For example: <tr><form><td> and </tr></form></td>
This is not specifically WC3 compliant, but it works :-)


For quantity selection, substitute a text box in place of the hidden field.

clip0207
<input type="text" name="quantity" value="18" size="2" maxlength="2">


A drop-down selection box can be substituted for to offer only fixed quantities.

clip0208
<select name="product">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>


Add to Cart Order-Link Hyperlink With Text Or Image
A hyperlink may be used instead of the form.
<a href="http://www.yourdomain.com/ashop/basket.php?quantity=1&product=1&add=1">Add to Cart</a>
or an image.
<a href="http://www.yourdomain.com/ashop/basket.php?quantity=1&product=1&add=1"><img src="addtocart.gif"></a>

Change the quantity= and product= parameters accordingly.
The productid is listed next to each product in Edit Catalog.

clip0206

Single Product Order Link
Omit the add=1 parameter for single product orders. This will clear the basket each time before the product is added.
<href="http://yourdomain.com/ashop/shipping.php?quantity=1&product=1&action=checkout">Buy Now</a>

To go directly to the payment form without viewing the cart.
http://www.yourdomain.com/ashop/shipping.php?quantity=1&product=1&action=checkout
Note that if the product has shipping or taxable set, the shipping information form will appear first.

View Cart Text Link
<href="http://www.yourdomain.com/ashop/basket.php">View Cart</a>

Check Out Text Link
<href="http://www.yourdomain.com/ashop/shipping.php?action=checkout">Check Out</a>

View Cart Image Link
<http://www.yourdomain.com/ashop/basket.php><img src="viewcart.gif"></a>

Check Out Image Link
<http://www.yourdomain.com/ashop/shipping.php?action=checkout><img src="checkout.gif"></a>

View Cart Form Button
<form method="get" action="http://www.yourdomain.com/ashop/basket.php">
<input type="submit" name="Submit" value="View Cart"></form>

clip0209
Check Out Form Button
<form method="get" action="http://www.yourdomain.com/ashop/shipping.php">
<input type="hidden" name="action" value="checkout">
<input type="submit" name="Submit" value="Check Out"></form>

clip0210
Return URL (Link from thank you page)
The default URL for the "Link from thank you page" is set in Shop Parameters. It may be overridden and specified for each order by including a returnurl parameter in the Order-Link checkout URL. The returnurl is stored in the orders table and used for the thank you page "Back to (ashopname)" URL after payment has been processed.

The following example sets the return URL to http://www.mydomain.com/mypage.html.
http://www.yourdomain.com/ashop/shipping.php?action=checkout&returnurl=http://www.mydomain.com/mypage.html
http://www.yourdomain.com/ashop/shipping.php?product=111&quantity=1&returnurl=http://www.mydomain.com/mypage.html

How to include attributes in Order-Link URLs
The Order-Link method can be used to set an attribute by posting the parameter "attribute" with the value "$attributeid:$valueid" to shipping.php, like this:
http://www.yourdomain.com/ashop/shipping.php?product=123&quantity=1&attribute=34:56

If there is only one attribute, it is simple to copy the URL from the link tool, which is displayed in the attribute alternatives page.

clip10084


To specify more than one attribute, put a separator between each attribute:alternative parameter like this.
http://www.yourdomain.com/ashop/shipping.php?product=123&quantity=1&attribute=34:56|43:81

URLs are not automatically generated by the link tool for multiple attributes and alternatives, however the individual parameters can be obtained by viewing each of the attribute alternatives and then appended to create each combination of attributes and alternatives. The parameters can be obtained by viewing the Order-Link for each alternative.

clip10085

It may help to make a chart. For example. Lets say that we have a t-shirt product, which is available in 2 colors and 4 sizes. The parameters in the left column are for white or black and the parameters accross the top are for sizes. The attributes and alternatives are combined for each possiblity where they intersect in the chart.


Sml 65:708
Med 65:709
Lrg 65:710
XL 65:711
White 68:718
68:718|65:708
68:718|65:709
68:718|65:710
68:718|65:711
Black 68:719
68:719|65:708
68:719|65:709
68:719|65:710
68:719|65:711


The appended attributes can be used to create an individual buy now link for each combination.
For example, this link would buy one small white shirt.
http://www.yourdomain.com/ashop/shipping.php?product=151&quantity=1&attribute=68:718|65:708

To change the link so that more than one product can be added to the cart, include the "add=1" attribute.
http://www.yourdomain.com/ashop/shipping.php?product=151&quantity=1&add=1&attribute=68:718|65:708


To create a form with drop-down selectors, copy the Order-Link form code from the link code generator for the main product.

clip10086
The form code can then be modified to work in various ways. Here is is cleaned up and aligned so that it makes more sense.

<form action="shipping.php" method="post">
<input type="hidden" name="product" value="151">
Quantity: <input type="text" name="quantity" size="5" value="1">
Sizes: <select name="attribute65">
<option value="708">Sml
<option value="709">Med
<option value="710">Lrg
<option value="711">X L</select>
Color: <select name="attribute68">
<option value="718">White
<option value="719">Black</select>
<input type="submit" value="Buy now">
</form>


The form code copied directly from the AShop admin panel is for buying a single item. When a product is added, any previous products are cleared from the basket. To convert the form into an Add to cart button, include the "add=1" parameter so that more than one product can be added to the cart. To view the basket before requesting shipping information, change the form action="shipping.php" to form action="basket.php". Here is an example.

<form action="basket.php" method="post">
<input type="hidden" name="add" value="1">
<input type="hidden" name="product" value="151">
Quantity: <input type="text" name="quantity" size="5" value="1">
Sizes: <select name="attribute65">
<option value="708">Sml
<option value="709">Med
<option value="710">Lrg
<option value="711">X L</select>
Color: <select name="attribute68">
<option value="718">White
<option value="719">Black</select>
<input type="submit" value="Buy now">
</form>