jpetersen
Starting Member
19 Posts |
Posted - February 05 2004 : 11:56:09
|
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
|
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
|
|
|