Hi I am new at this, and am trying to cusomize a sales cart
application for my web.
The boxed application allows you to select either discounts per item
or whole order discounts. All of my products would fit into the whole
order discount category, but I have one that is not elligeble for a
discount at all!
The whole order discount is setup to start when order total is equal
or over $600 and the discount ammount is a fixed amount of $60. The
item that is not elligeble for a discount costs $1215. How can I
modify the code to put an exclusion criteria for that item when
calculating the whole order discount?

Here is the code on the page:
<%@ LANGUAGE="VBScript.Encode" %>
<!--#include virtual="/cgi-bin/GetOrder.asp"-->
<!--#include virtual="/cgi-bin/codepage.asp"-->
<!--#include virtual="/cgi-bin/ADOVBS.inc"-->
<!--#include virtual="/cgi-bin/IASUtil.asp"-->
<%
coupon = FGETVar("coupon","","s")

'READ STUFF From Database
Dim objSimpleAdo, rstRS, SQLStmt

SQLStmt = "SELECT * From item "
SQLStmt = SQLStmt & "WHERE [Orderid] =" & Order & "; "

Set SimpleAdo = New CSimpleAdo
SimpleAdo.setConnectionString = Session("ConnectionString")
Set RS = SimpleAdo.getRecordSet(SQLStmt)
'Do stuff with the record set

'Initialize variables for this application
thedate = Cstr(Date) 'get the date
thetime = Cstr(Time) 'get the time

subtotal = 0 'the subtotal for a row of items
subweight = 0 'the subweight for a row of items
subsize = 0 'the subsize for a row of items
subquantity = 0 'the subquantity for a row of items
subship = 0 'the subshipping for a row of items
subhand = 0 'the subhandling for a row of items

%>


<%
'Calculate the individual totals for a row
subweight = subweight + (RS("Quantity") * RS("Weight"))
subsize = subsize + (RS("Quantity") * RS("Size"))
subtotal = (RS("Quantity") * RS("Price"))
subquantity = subquantity + RS("Quantity")
subship = subship + (RS("Quantity") * RS("ExtraShip"))
subhand = subhand + (RS("Quantity") * RS("ExtraHand"))
total = MyCurrency (CCur(subtotal))
grandtotal = grandtotal + subtotal
%>

'Do item discount
If RS("Price") <> 0 Then
If RS("Price")/RS("RawPrice") <> 1 Then
itemdiscount = 100-(RS("Price")/RS("RawPrice") * 100)
strdisplay = "<font color=#BB0000> (" & Round(itemdiscount,2) & "%
off)</font>"
Response.write(strdisplay)

End If
End If

'Here is where I think the code should be modified. I tried several
ways but it does not work
<%'do whole order discount here Original
'Dim discountarray(1)
Set DiscountObj = New CDiscountObj
'If RS("Price") = 1215 Then
'discountarray = DiscountObj.wholeDiscount (subtotal + 60)
'Else
discountarray = DiscountObj.wholeDiscount (grandtotal)
'End If
'discountarray(1) = DiscountObj.wholeDiscount (grandtotal)
'discountarray(2) = "HELOOOOOOOOOOOO"



Set DiscountObj = Nothing


'Next do COUPON DISCOUNTS
If Session("ChkCoupons") > 0 then
'Dim discountarray(0)
'If RS("Price") = 1215 Then
'discountarray = 0
'Else
Set DiscountObj = New CDiscountObj
discountarray = DiscountObj.couponDiscount (discountarray,coupon)
Set DiscountObj = Nothing
'End If
End If

%>

<%
If discountarray(0) = 1 Then
If RS("Price") = 1215 Then
Response.write("<font color=#BB0000>(Total was " & MyCurrency
(CCur(discountarray(1))) & " Discounts do not apply to webinars)</
font>")
Else
Response.write("<font color=#BB0000>(Total was " & MyCurrency
(CCur(discountarray(1))) & " Discount of $60.00 Applied)</font>")
Response.write (MyCurrency (CCur(RS("Price"))))
End IF
End If
%>

Any help would be appreciated!
PS. I omited the HTML tables that display the results.

Re: Help with VBscript to calculate total order discount on sales by mr_unreliable

mr_unreliable
Fri Jul 27 11:50:43 CDT 2007

marias wrote:
> Hi I am new at this, and am trying to cusomize a sales cart
> application for my web.

hi Marias,

I usually charge a humongous fee for something like this,
but I am feeling generous today.

First, while you are stepping through your cart items,
test for the "discount-excluded" item. If you find it
store a flag (bExcludedItem = True), plus store the single
item amount, and if the customer is purchasing more than
one the total for that item.

Second, (still in the loop) if the current item is the
"discount-excluded" item, then bypass the discount
calculation code.

Lastly, after computing the gross bill, subtract any
total you may have previously stored for the "discount-
excluded" item, before applying whole order discount,
if any...

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)

p.s. if you want me to write code for you, I _do_ charge for
that, and trust me -- you won't be able to afford the expense...