Shopping Cart Example (Shopping cart page)

Source: Internet
Author: User
Tags chr empty include variable
<!--checkbag.asp-->

<!--ShoppingCart page-->

<%
Response.Expires = 0
Response.ExpiresAbsolute = Now ()-1
Response.AddHeader "Pragma", "No-cache"
Response.AddHeader "Cache-control", "private"
Response.CacheControl = "No-cache"
%>

<!--#include file= "conn.asp"-->
<!--#include file= "Char.inc"-->

<%
' Id_type=request ("Id_type")
Obj=request ("obj") ' is used to detect whether it is a normal purchase after the entry into the shopping cart fetch obj parameters
Rid=session ("id") ' Take out member ID
Dim x,i
Dim Obj_bag,bag_item,cart
' Obj_bag----Shopping cart
' Bag_item----Product Information data collection
' Cart----Information data collection for a product
Dim p_id,p_name,p_price,p_manu,p_type,p_size,p_color,p_num,p_total,sum
' P_ID----Product ID number
' P_name----Product Name
' P_price----Price
' P_manu----manufacturer
' P_type----Product style
' P_size----size
' P_color----Color
' P_num----Quantity
' P_total----Subtotal
' Sum----total amount

Dim id1

If obj= "1" then obj is 1 description by the menu bar click into the
If not IsObject ("Bag") then if the session ("Bag") is not an object, the cart is empty
Response.Write "<script language=" "JavaScript" ">"
Response.Write "Alert (" "Shopping cart is empty!"); "& Chr (13)
Response.Write "window.location= ' index.asp '"
Response.Write "</script>"
Response.End
Else
Set Obj_bag=session ("bag") if the shopping cart is not empty, assign it to an object obj_bag
End If
Else
If IsObject ("Bag") then the shopping cart information to an object if the menu bar clicks on it obj_bag

Set Obj_bag=session ("Bag")
else if the shopping cart is empty, indicating that there is no merchandise in the cart, then back to the page
Response.Write "<script language=" "JavaScript" ">"
Response.Write "Alert (" "t shopping cart is empty!"); "& Chr (13)
Response.Write "window.location= ' index.asp '"
Response.Write "</script>"
Response.End
End If
End If
' Response.Write ' <script>alert ("" "& IsObject (obj_bag) &" "") </script> "

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Decide which button is clicked on the bottom of the shopping cart page.
''''''''''''''''''''''''''''''''''''''''

Select Case Request ("action") Get the button information
Recalculate value and total price of commodity if refresh is selected
Writes the current information to the shopping cart and displays the cart
Case "Refresh" if the Refresh
For each cart in Obj_bag.items
P_name=cart (0) Assign the information data set in the shopping cart to the variable
P_manu=cart (1)
P_type=cart (2)
P_size=cart (3)
P_color=cart (4)
P_price=cart (5)
P_num=cart (6)
P_id=cart (7)

If Request ("Checkbox_" & p_id) <> "" Then gets the value of canceling the radio box, and if not NULL, tick
If Obj_bag. Exists (P_name) Then if a product already exists delete the product
Obj_bag.remove (P_name)
End If
Else
P_num=trim ("Quantity" &p_name) if there is no such action, write to the cart
if (not IsNumeric (p_num)) or (p_num<= "0") or (InStr (1,p_num, ".") <>0)) Then
P_num=1
End If
Bag_item=array (p_name,p_manu,p_type,p_size,p_color,p_price,p_num,p_id)
' Response.Write ' p_num= ' & p_num & ' <br> '
End If
Next
The set session ("Bag") =obj_bag the information in the Obj_bag object and writes to the session ("Bag")

If you choose to go to the cashier, prepare to start receiving payment
Writes the current information to the shopping cart and turns to the cashier program
Case "Check" button for the time of purchase
For every cart in Obj_bag.items loop cart assigns all of its information to a variable
P_name=cart (0)
P_manu=cart (1)
P_type=cart (2)
P_size=cart (3)
P_color=cart (4)
P_price=cart (5)
P_num=cart (6)
P_id=cart (7)

If Request ("Checkbox_" & p_id) = "" Then if the uncheck box is empty, the ID1 value is taken
ID1=P_ID & "," & ID1 will they have a comma-form connection
End If
Next
Id1=left (Id1,len (ID1)-1)
Shopping_id=request ("id")
Set Obj_bag=session ("Bag")
Set session ("Obj_bag") =obj_bag
Call Insertdb (ID1) calling function
End Select
%>
' Output HTML
。。。。。。。。。 Slightly


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.