%
strID = Request("id")
strID = killC(strID)
if strID <> "" then
strID = int(strID)
end if
strPorL = Request("PorL")
strPrimCat = Request("primcat")
strSubCat = Request("subcat")
if strID = "" then
strID = "4"
end if
if strPorL = "" then
strPorL = "1"
else
strPorL = int(strPorL)
end if
if strPrimCat = "" then
strPrimCat = "0"
else
strPrimCat = int(strPrimCat)
end if
if strSubCat = "" then
strSubCat = "1"
else
strSubCat = int(strSubCat)
end if
if left(strPath, 1) = "p" then
strRootPath = "pdetails"
else
strRootPath = "plists"
end if
iaction = Request("action")
Dim bFoundMatch
bFoundMatch = false
bProceed = true
StrPickOptions = Request.Cookies("gl")("pick")
if StrPickOptions = "" then
StrPickOptions = "0`0`No pickling or bagging"
end if
Response.Cookies("gl")("pick") = StrPickOptions
if (iaction = "add") then
%>
<%
strSQL = "SELECT * FROM glitems where id=" & strID
Set rs = my_conn.Execute(strSQL)
strProduct = rs("Name")
strPrice = rs("Price")
' StrID
strTCode = rs("ITCode")
strWeight = rs("Weight")
strbHH = rs("HHProduct")
strHHPrice = rs("HHPrice")
strbSeed = rs("SeedProduct")
if strbSeed = "1" then
strPickQ = ""
strSQL = "SELECT * FROM glitems2 where id=" & strID
Set rs2 = my_conn.Execute(strSQL)
strPickOpt = rs2("Pick")
strPickQ = ""
if strPickOpt <> "" then
strPickSplit = split(strPickOpt, "|")
for i = 0 to ubound(strPickSplit)
if isnumeric(strPickSplit(i)) = true then
if strPickQ <> "" then
strPickQ = strPickQ & " OR ID=" & int(strPickSplit(i))
else
strPickQ = " WHERE ID=" & int(strPickSplit(i))
end if
end if
next
' Now we have all the pickling options for this product so let us add them to the cookie for info
strSQL = "SELECT * FROM glpick" & strPickQ
Set rs2 = nothing
Set rs2 = my_conn.Execute(strSQL)
StrPickOptions = Request.Cookies("gl")("pick")
' PICK = ID`PRICE`TEXT`~ID`PRICE`TEXT...
' Check to make sure this pick options does not already exist
bPickMatch = false
if not rs2.EOF then
do while not rs2.EOF
strPickID = rs2("ID")
bPickMatch = false
if StrPickOptions <> "" then
strPickSplit = split(strPickOptions, "~")
for i = 0 to ubound(strPickSplit)
strPickSplitO = split(strPickSplit(i), "`")
if ubound(strPickSplitO) > 0 then
if int(strPickSplitO(0)) = int(strPickID) then
bPickMatch = true
end if
end if
next
if bPickMatch = false then
' Add it
StrPickOptions = StrPickOptions & "~" & rs2("ID") & "`" & rs2("Price") & "`" & rs2("Descrip")
end if
else ' Just add it as there is no options at the moment
StrPickOptions = "0`0`No pickling or bagging~" & rs2("ID") & "`" & rs2("Price") & "`" & rs2("Descrip")
end if
rs2.MoveNext 'Next record
loop
end if
end if
Response.Cookies("gl")("pick") = StrPickOptions
end if
'response.write strpickoptions
strInStock = rs("InStock")
strWSPrice = rs("WSPrice")
StringInStock = strInStock
if (isnumeric(strInStock) = false) then
strInStock = -1
else
strInStock = int(strInStock)
if (strInStock < 0) then
strInStock = -1
end if
end if
if strTCode <> "" then
bFoundMatch = false
spItem = Request.Cookies("gl")("items")
if (spItem <> "") then
SItems = Split(spItem, "~")
NewCookie = ""
for Index = 0 to ubound(SItems)
ItemData = Split(SItems(Index), "`")
' 0 is Quantity
' 1 is Name
' 2 is Price
' 3 is Location
' 4 is IT Code
' 5 is weight
' 6 is HappyHour Product? 0:No 1:Yes
' 7 is HappyHour Price
' 8 is Seed Product? 0:No 1:Yes
' 9 is InStock
if ubound(ItemData) => 9 then
if (ItemData(4) = strTCode) then
' DONOT Remove this one
bFoundMatch = true
end if
end if
next
end if
if (bFoundMatch = false) then ' The product doesnt exist so add it
' Now add it to our product cookie
strItems = Request.Cookies("gl")("items")
if (strPrice = "") then
strPrice = 0
end if
if strInStock = "-1" or strInStock = "" then
bStock = false
else
bStock = true
end if
if (strbSeed = "1" or bStock = true) then ' Its seed or a limited stock item
' Now do we have more stock than what they want?
if (strInStock >= 1 and strInStock > 0) then
bProceed = true
else ' We dont have enough, tell them to change the order
bProceed = false
if strbSeed = "1" then
strStringSeed = " Kg's"
else
strStringSeed = ""
end if
StrGrain = StrGrain & "
" & strProduct & " x 1 " & strStringSeed & " is unavaliable [ Please call us ] (GL Code: " & strTCode & ")"
end if
end if
if (bProceed = true) then
' 0 is Quantity
' 1 is Name
' 2 is Price
' 3 is Location
' 4 is IT Code
' 5 is weight | Pickling Options
' 6 is HappyHour Product? 0:No 1:Yes
' 7 is HappyHour Price
' 8 is Seed Product? 0:No 1:Yes
' 9 is InStock
' 10 is Wholesale price
if (StringInStock = "") then
StringInStock = "-1"
end if
if strbSeed = "1" then
StrWeight = strPickOpt
end if
Response.Cookies("gl")("items") = strItems & "~1`" & strProduct & "`" & strPrice & "`" & strID & "`" & StrTCode & "`" & StrWeight &_
"`" & strbHH & "`" & strHHPrice & "`" & strbSeed & "`" & StringInStock & "`" & strWSPrice
end if
end if
'response.write("=" & Request.Cookies("gl")("items"))
else
Response.write("
** Could not add item **
") end if my_conn.close ' Close database connection Set my_conn = nothing 'obj variable released Set rs = nothing elseif (iaction = "delete") then ' Lets cycle through the products and delete the one we dont want spItem = Request.Cookies("gl")("items") strID = Request("id") if isnumeric(strID) = false then strID = int(strID) end if if (spItem <> "") then SItems = Split(spItem, "~") NewCookie = "" for Index = 0 to ubound(SItems) ItemData = Split(SItems(Index), "`") ' 0 is Quantity ' 1 is Name ' 2 is Price ' 3 is Location ' 4 is IT Code ' 5 is weight ' 6 is HappyHour Product? 0:No 1:Yes ' 7 is HappyHour Price ' 8 is Seed Product? 0:No 1:Yes ' 9 is InStock ' 10 is Wholesale price if ubound(ItemData) => 9 then if (ItemData(3) <> StrID) then ' DONOT Remove this one NewCookie = NewCookie & "~" & SItems(Index) end if end if next end if Response.Cookies("gl")("items") = NewCookie elseif (iaction = "update") then ' This is for changing quantities iIndex = 0 StringItem = Request.Form("qty" & iIndex) StringItem = int(StringItem) spItem = Request.Cookies("gl")("items") if (spItem <> "") then SItems = Split(spItem, "~") NewCookie = "" %> <% for Index = 0 to ubound(SItems) if isNumeric(StringItem) = false then StringItem = 1 end if if StringItem <= 0 then StringItem = 1 end if ItemData = Split(SItems(Index), "`") ' 0 is Quantity ' 1 is Name ' 2 is Price ' 3 is Location ' 4 is IT Code ' 5 is weight ' 6 is HappyHour Product? 0:No 1:Yes ' 7 is HappyHour Price ' 8 is Seed Product? 0:No 1:Yes ' 9 is InStock ' 10 is Wholesale price if ubound(ItemData) => 9 then if ItemData(9) = "-1" then bStock = false else bStock = true end if if (ItemData(8) = "1" or bStock = true) then ' Its seed or a limited stock item ' Request the pickling strPickSTRING = Request.Form("pickling" & iIndex) ' So we have pickling value now we need to read it and ajust weight ItemData(5) ' If it has changed then we put the value to the front if strPickSTRING <> "" then strPick = split(StrPickSTRING, ".") strPickNum = strPick(0) strPick = split(ItemData(5), "|") if ubound(strPick) > 0 then ItemData(5) = strPickNum & "|" for m = 0 to ubound(strPick) if strPick(m) <> "" then if int(strPick(m)) <> int(strPickNum) then ItemData(5) = ItemData(5) & strPick(m) & "|" end if end if next end if end if strSQL = "select * from glitems where ID=" & ItemData(3) Set rs2 = my_conn.Execute(strSQL) strInStock = rs2("InStock") strInStock = int(strInStock) if (strInStock < 0) then strInStock = 0 end if ' Now do we have more stock than what they want? if StringItem <= strInStock and strInStock > 0 then else ' We dont have enough, tell them to change the order bProceed = false if ItemData(8) = "1" then strStringSeed = " Kg's" else strStringSeed = "" end if StrGrain = StrGrain & "
Shopping Cart
<%
Response.write("
|