Use a FORM, on your web page, to add an Item directly to the shopping cart.
This Method DOES NOT REQUIRE the Item/Product to be in the database.
You must enter all of
the product's information, into the form fields.
To use this Method do the following:
1. Copy the following code into the page above the <html> tag.
Here we set the
Cart Id to keep track of
the customer's items in the cart.
This should be the very first thing, on every page, for which you want to put items.
Save the page with a (dot) .asp extension.
*Note: Copy and paste into notepad to
remove formatting then copy and paste into your html.
<! === Start Copying
the "Set Cart Id code" below this line. *Note: You need the <% and %> code too
=== >
<%
Dim strCartId
IF
Session("CartId") <> "" THEN
strCartId =
Session("CartId")
ElseIF NOT
Request.Cookies("CartId").HasKeys THEN
strCartId =
Session.SessionId
Session.Timeout =
180
Session("CartId")
= Session.SessionId
ELSE
strCartId =
Request.Cookies("CartId")("CartId")
Session.Timeout =
180
Session("CartId")
= strCartId
END IF
If Session("CartId") <> "" Then
Else
Session("CartId") = Session.SessionId
Session.Timeout = 60
End If
Response.Cookies("CartId")("CartId")
= strCartId
Response.Cookies("CartId").Expires
= Now() + 9999
%>
<! ======================== End
Set Cart Id code above this line =========================
>
OR use the cartid.asp
include page instead of the script above. e.g. <!--#include
file="cartid.asp"--> place in the page before the <html>
tag. Your page must be in the scart folder or change the path. e.g. <!--#include
file="scart/cartid.asp"--> The cartid.asp page has the above
script in it.
2. Copy the following FORM html code into the page
and edit as needed.
*Note:
The Form is explained in detail at the bottom of this readme file. Please
read it.
Copy the Form into the page near the Item
that you want to sell. (below, above or beside it)
You may place the form fields at ANY
POSITION in the page AS LONG AS THE FIELDS ALL STAY WITHIN THE
<FORM> and </FORM> Tags.
[ Example
Page ]
*Note: Copy and paste into
notepad to remove formatting then copy and paste into your html.
<!-- ======================== Start Copying the Form below this line ===================== --->
<form method="POST" action="cart_form_add.asp"
name="add_to_cart">
<input type="text" name="Quantity" size="4" value="1">
<select size="1" name="OptionSet1">
<option value="Small" selected>Small</option>
<option value="Medium">Medium</option>
<option value="Large">Large</option>
<option value="XLarge">XLarge</option>
<option value="XXLarge">XXLarge</option>
<option value="XXXLarge">XXXLarge</option>
</select>
<select size="1" name="OptionSet2">
<option value="Red" selected>Red</option>
<option value="White">White</option>
<option value="Blue">Blue</option>
</select>
<select size="1" name="OptionSet3">
<option value="Round" selected>Round</option>
<option value="Square">Square</option>
</select>
<input type="hidden" name="CartId" value="<%= strCartId %>">
<input type="hidden" name="ItemNum" value="Your-Item-Number">
<input type="hidden" name="Description" value="Type your description here.">
<input type="hidden" name="Weight" value="1">
<input type="hidden" name="Price" value="125.25">
<input type="hidden"
name="Page" value="shop_template.asp">
<input type="submit" value="Add to Cart" name="B1" style=" border: 1 solid blue;
background-color:black;
font-family: Verdana; font-size: 8pt; color: white;">
</form>
Optional Fields
Use the
following two optional fields if the items is downloadable.
1. <input type="hidden" name="Download" value="Yes">
2. <input type="hidden" name="FileName" value="program.exe">
1. Download = Yes
(tells the systems this is a downloadable item)
2. FileName =
yourfilename (put the file in your scart/pd folder and enter the exact file
name)
Adding these two
hidden fields will make your item downloadable at check out.
If the item is not
downloadable omit these two fields.
<!-- =======================Stop Copying Form above this
line===================== -->
[ Example
Page ]
<!-- ============================Form Breakdown============================ --->
01. <Form method="POST"
action="cart_form_add.asp" name="add_to_cart">
02. <input type="text" name="Quantity" size="4" value="1">
03. <select size="1" name="OptionSet1">
04. <option value="Small" selected>Small</option>
05. <option value="Medium">Medium</option>
06. <option value="Large">Large</option>
07. <option value="XLarge">XLarge</option>
08. <option value="XXLarge">XXLarge</option>
09. <option value="XXXLarge">XXXLarge</option>
10. </select>
11. <select size="1" name="OptionSet2">
12. <option value="Red" selected>Red</option>
13. <option value="White">White</option>
14. <option value="Blue">Blue</option>
15. </select>
16. <select size="1" name="OptionSet3">
17. <option value="Round" selected>Round</option>
18. <option value="Square">Square</option>
19. </select>
20. <input type="hidden" name="CartId" value="<%= strCartId %>">
21. <input type="hidden" name="ItemNum" value="Your-Item-Number">
22. <input type="hidden" name="Description" value="Type your description here.">
23. <input type="hidden" name="Weight" value="1">
24. <input type="hidden" name="Price" value="125.25">
25.
<input type="hidden" name="Page"
value="shop_template.asp">
26. <input type="submit" value="Add to Cart" name="B1" style=" border: 1 solid blue; background-color:black;
font-family: Verdana; font-size: 8pt; color: white;">
27. </form>
Optional Fields
Use the
following two optional fields if the items is downloadable.
1. <input type="hidden" name="Download" value="Yes">
2. <input type="hidden" name="FileName" value="program.exe">
1. Download = Yes
(tells the systems this is a downloadable item)
2. FileName =
yourfilename (put the file in your scart/pd folder and enter the exact file
name)
Adding these two
hidden fields will make your item downloadable at check out.
If the item is not
downloadable omit these two fields.
<! ==============================Form
Explanation================================= >
01. The FORM TAG. Method must be POST. The action depends on what folder
you put the page (see a and b below).
a. If your new page is going to sit in: www.yourdomain.com/new-page.asp
Then the Action would be:
action="scart/cart_form_add.asp"
because your page is in a folder above the cart_form_add.asp page.
b. If your new page is going to sit in:
www.yourdomain.com/scart/new-page.asp
Then the Action would be:
action="cart_form_add.asp"
because your page is in the same folder as the cart_form_add.asp page.
02. The Quantity Input Box. This box allows a customer to choose how many of this Item they want to buy.
Required!
[ Breakdown
]
03. OptionSet1. (Optional)
This select box and the next two select boxes (items 11 and 16 above) are optional.
You can use up to 3 Select boxes for each product/item if
needed.
If your product has options, you can use these
select boxes to allow a customer to pick their option. If used, the values
chosen by the customer, are included in the order.
If used, Option1 box MUST be named OptionSet1
04. Select option. (Applies to 04 thru 09 in the breakdown above.)
You can have as many selections, per Select Box, as you need, just add more option values.
e.g <option value="Medium">Medium</option>
(you're not limited to 12 as with the database).
10. End Select Box.
11. OptionSet2. Second Select Box. Use is Optional. If used, must be named OptionSet2. Explanations 03 and 04 above apply.
[ Breakdown
]
16. OptionSet3. Third Select Box. Use is Optional. If used, must be named OptionSet3. Explanations 03 and 04 above apply.
20. CartId Field. This is a hidden field. It is required.
CartId field gets the CartId, from the
Session Variable that we set in the script above, and marks all items in the cart as belonging to this customer.
21. ItemNum Field. This is a hidden field. It is required.
ItemNum is your product's Item Number.
Use Numbers, Letters
and/or a dash (hyphen " - '). No Spaces. This Field IS Required.
[ Breakdown
]
22. Description Field. Type the Product's Description.
Try to keep the description to 50 characters max. However, the database cart table will allow up to 150 characters for this field.
23. Weight Field. The weight field is used to calculate Shipping. THIS FIELD IS REQUIRED!
The weight field is multiplied by whatever your base shipping unit is set at on your company info page.
e.g. If the Base Unit = 6.00 and you set the weight field to ".5" the shipping for this Item would be $3.00.
If the Base Unit = 6.00 and you set the weight field to "1" the shipping for this Item would be $6.00.
If the Base Unit = 6.00 and you set the weight field to "1.5" the shipping for this Item would be $9.00.
If the Base Unit = 6.00 and you set the weight field to "2" the shipping for this Item would be $12.00.
And so on and so on.
[ Breakdown
]
24. Price Field.
THIS FIELD IS REQUIRED!
Set the price for the Item/Product.
Use Numbers and a period only. NO DOLLAR SIGNS!
e.g. value="125.25"
25.
Page Field (optional)
The Page field
is there so that we can send the page file name/url to the cart view page. If
this field is used, the "Continue Shopping" link, on the cart view
page, will take the user back to the page they came from. If not used remove
it completely.
To use this
field enter the name of the page. Whatever name you use when you "Save
As" that is the value of this field. e.g.
value="shop_template.asp" or
value="my-page.asp"
*Note - If your
page is outside of the cart folder then add ../ preceding the file name e.g.
../my-page.asp
(see #7 in notes
below)
26. Submit Button
I left the custom tags in so you can change the button colors:
style=" border: 1 solid blue; background-color:black; font-family: Verdana; font-size: 8pt; color: white;"
It will accept html color codes e.g. #0066FF or html color names e.g. LightBlue or Blue
[ Breakdown
]
27. End FORM Tag
*Notes:
1. Copy the Form into the page near the Item you want to sell. (below, above or beside it)
2. You may place the form fields at ANY POSITION in the page AS LONG AS THE FIELDS ALL STAY WITHIN
THE <FORM> and </FORM> Tags.
3. All form fields must RETAIN their ORIGINAL NAME value. e.g. name="Quantity" the word Quantity cannot change.
4. All fields other than the Option Select Boxes and Page field, are required.
5. The Weight and price fields MUST contain only numbers. e.g. 1 or 1.25 or 100.32 DO NOT USE THE $ SIGN.
6. The Item/Product does NOT HAVE TO BE in the Database.
7. PUT ALL YOUR
PAGES IN THE scart FOLDER. This will greatly simplify the urls in the links.