Order-Link Ordering Method
Previous  Top  Next


The Order-Link method supports Add to Cart, View Cart, and Check Out functionality within HTML pages. The Order-Links may be located on the local server, on a remote server, or within email messages.

Order-Link Code Basic Behavior and Customization
The basic Order-Link html code may be copied directly from each product listing in the AShop admin panel and pasted directly into the source code of a web page, however typically modifications are needed so that it works best within the context of each store design, for the marketing method, and for the type of products that are being sold. This topic describes the basics of the html code. For additional step by step examples and screen shots also see the Order-Link Tech Tip
.

The three main scripts used for Order-Link are shipping.php, basket.php, and checkout.php. The scripts may be run by linking to them or from an html form post. Parameters are added to specify product information and Order-Link behavior.

Customer Shipping/Tax Information Form Page
Products that are shippable or taxable require collection of shipping information from each customer. The shipping information must be collected sometime before checkout, but it is optional to ask for it during the shopping session or at checkout. Use shipping.php for buy buttons to collect the shipping address before viewing the cart. Use basket.php for buy buttons to allow shopping before entering the shipping address.

shipping.php - The shipping.php script is used to add products to the cart and to collect address information for shipping or sales tax. It can also be used for checkout by specifying the parameter "action=checkout" in the link. The Order-Link (buy link/button) html code that is copied directly from the AShop admin panel runs the shipping.php script. With shipping.php, when shippable or taxable products are added to the cart the shipping information form appears (before the View Cart page) so that shipping and taxes will be included in the View Cart page from the beginning of the shopping session.

basket.php - The basket.php script is used to add products to the cart or to view the cart contents. To View Cart, link to basket.php without any parameters. For Add to Cart and Buy links, parameters must be added to specify the products. When a product is added to the cart with a link to basket.php, the View Cart page opens (without first asking for shipping address first) even if shippable or taxable products are added. In the View Cart page there will be a link to calculate shipping/taxes. With this method, it is optional for customers to click the calculate shipping/taxes link in the View Cart page at any time during the shopping session. If the shipping address is needed and it has not been entered yet, the shipping address page will open before checkout can be completed. The Order-Link (buy link/button) html code that is copied directly from the AShop admin panel runs the shipping.php script. To change the shipping address behavior as described, change the Order-Links so that they link to the basket.php script instead.

add=1 Parameter
The Order-Link (buy link/button) html code that is copied directly from the AShop admin panel does not include an add=1 parameter. This must be added in order to allow more than one product to be added to the cart. If the add=1 parameter is not included, each time a product is added it will replace any previously added product. See examples below....

checkout.php - If there are shippable or taxable products in the cart, links to checkout.php will open the shipping information page (shipping.php). When the shipping address is submitted, the checkout will continue to the payment form page or the payment option selection page (depending on if there is more than one payment option). If there are not any shippable or taxable products in the cart, a link to checkout.php will go directly to the payment page or payment options.


How to Create an Add to Cart Order-Link Form
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 (for products without attributes) 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 may cause unwanted enlargement of the table cell and distort the intended page design in some browsers. 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 it is cleaned up and aligned so that it is easier to read.

<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 add=1 Parameter
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>


Language Preference and Order-Link

Language preference must be set at the beginning of each shopping session. This is done by linking to the language.php script with language and redirect parameters. Here is an example:
http://yourdomain.com/ashop/language.php?language=sp&redirect=http://www.yourdomain.com/SpanishOrderPage.html

By running the language.php script first, it sets the language preference in a cookie and redirects to the Spanish order page. Then when products are added to the basket, the AShop scripts will read the language preference from the cookie and display View Cart and other pages in the same language. When the customer checks out the language preference is saved in the database so that future receipts and notices will be in the same language for each customer.