Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shopping cart variable postage count??

Status
Not open for further replies.

techskool

Technical User
Jun 20, 2002
151
GB
I have a shopping basket, which i need to to add some code to for variable postage.:

Ive ommited all the html i would write on the fly here:

A loop includes this:
**************
qtyprice = Price * qtyselected

dblTotalPrice = cDbl(dblTotalPrice) + cDbl(qtyprice)
**************

I take the price field out of the db, and set its total equal to how many are selected.

for example for one item, its variable costs, depending on quantity could read in like this:
------------
qtyprice = Price * qtyselected
or
20 = 10 * 2
-------------

then
-------------
dblTotalPrice = cDbl(dblTotalPrice) + cDbl(qtyprice)
or
0 = 0 + 20
-------------

Then for each iteration of the loop the total cost will build up.

So we can see the first takes a total cost an item x how many are wanted.

Then we can see the second bit holds a total value for this previous value and keeps adding for each loop.

----


So, whats wrong here.

Well i need to add postage costs, at 2.00 for the first item selected, and 1.00 for every other item after the first.

How can this be achieved building on existing code, or adding new?

Thanks

Dave

 
Well here's one way to do it:

Within the loop to add a dollar each time:
dblTotalPostage = cDbl(dblTotalPostage) + 1

And after the loop to add a dollar because the first item is really supposed to be two dollars:
If dblTotalPostage > 0 Then
dblTotalPostage = dblTotalPostage + 1
End If



Best regards,
J. Paul Schmidt - Freelance ASP Web Developer
- Creating "dynamic" Web pages that read and write from databases...
 
Doh! of course.

It seems so simple AFTER youve been told!

Thanks friend

Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top