VP-ASP :: Shopping Cart Software

Shopping Cart Software Solutions for anywhere in the World

US/Canada(Toll Free): +1 888 587 2278
Europe/UK: +44 (020) 7193 9408
Australia/New Zealand: +61 3 9016 4497

VP-ASP Shopping Cart Customer Forum

Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VPCart Forum
 Customization
 Shipping surcharge based on weight and state
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jpetersen
Starting Member

19 Posts

Posted - February 05 2004 :  11:56:09  Show Profile  Visit jpetersen's Homepage  Reply with Quote
I'm wondering if anyone else out there has done something similar and can maybe lead me in the right direction.

I currently have my shopping cart setup to charge shipping based on the total cost of the order. However, I also need to add an additional surcharge for certain products that are overweight. However, the surcharge changes depending on the state the product is being shipped to.

So, my idea is to tell it to look at the weight field for each product ordered. If the weight field indicates a certain number, then the function would look at the state the items are being shipped to and determine the price based on that. It would then add that price to the shipping charge that has been calculated by price.

It sounds simple enough to me, but I'm new to ASP and I keep running into dead ends. A prod in the right direction would be very appreciated.

Thanks.

jpetersen
Starting Member

19 Posts

Posted - February 05 2004 :  18:48:13  Show Profile  Visit jpetersen's Homepage  Reply with Quote
After a long day and a headache... I finally figured it out. Thought I would share the fruits of my labor... mind you I'm a novice at ASP so it may not be as eloquent as some. Also, one could probably put the state and surcharge info into a table and retrieve it that way. But that will be a later project for me.

I made edits to the HandleByPriceRange sub on shopshippingcalc.asp

If anyone has any comments, please let me know.

Sub HandleByPriceRange
'**************************************************************************
' Use numer of items as shipping calculation
' Calculate fill Price
'**************************************************************************
Dim weight
Dim i
Dim ShippingPrice
Dim TotalPrice
Dim rsitem
Dim ShippingCost
dim rsitems
dim lowvalue, highvalue
dim shipsql
dim surcharge
dim catid
dim strSQLQuery
dim rscharge
dim prodid
dim Prodquantity
dim cartstate
'
TotalPrice=GetSess("OrderProductTotal")
If getconfig("Xdeliveryshipping")="Yes" then
CalculateTotalPrice totalprice
If totalprice=0 then exit sub
end if
ShopOpenDatabase dbc ' find
' Find the weight range using shipother1 and shipother2
'debugwrite "searching for " & shipmethod & " for Price " & totalPrice
' Reread database record for a particular method
shipsql="select * from shipmethods where shipmethod='" & shipmethod & "'"

AddShippingCountry shipsql,rsitems, dbc
do while not rsitems.eof
lowvalue=rsitems("shipcost1")
highvalue=rsitems("shipcost2")
'debugwrite "low=" & lowvalue & " high=" & highvalue
if totalprice >= lowvalue and totalprice < highvalue then
shipcost= rsitems("shipbasecost")
cartstate = GetSess("shipstate") 'sets the shipping state
scartItem = GetSess("CartCount") 'sets the cart count
arrCart = GetSessA("CartArray") 'sets the cart array
' go through all products
For i = 1 to scartItem
prodid=arrCart(cProductid,i) 'sets the prodid
Prodquantity=arrCart(cQuantity,i)
strSQLQuery = "SELECT * FROM products where catalogid='" & prodid & "'" 'gets the info from the db
set rscharge=dbc.execute(strSQLQuery) 'sets the info in a record set
surcharge = (rscharge("weight")) 'assigns the info to a variable to be printed
if cartstate = "OR" then ' build up your states and surcharges here
if surcharge = "1" then
shipcost = shipcost + (1.5 * Prodquantity)
end if
end if
' else
' shipcost= rsitems("shipbasecost")
next
closerecordset rsitems
ShopCloseDatabase dbc
SetSess "smprice",ShipCost
exit sub
end if
if totalprice >= 130 then 'calculates percent shipping after a certain point
shippingcost=totalprice*.14
shippingcost=formatnumber(shippingcost,2)
setsess "smprice",shippingcost
exit sub
end if
rsitems.movenext
loop
ShipCost=0
closerecordset rsitems
ShopCloseDatabase dbc
SetSess "smprice",ShipCost
SetSess "ShipCalc","Price Range"
end sub

Go to Top of Page

allieggwom
Starting Member

1 Posts

Posted - April 17 2008 :  19:06:13  Show Profile  Reply with Quote
Hi,
I'm going to try your code - unless you have something better you'd like to share. I have a similar shipping situation.

Allison G
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000