Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > shopping cart

Reply
Thread Tools

shopping cart

 
 
John Smith
Guest
Posts: n/a
 
      07-10-2003
Hi,

I'm trying to work out the postage rate for products in a shopping cart.
Predictably there is no formula for working out the postage rate (ie. 0.20 *
weight). The problem i'm having is with the statement for working this out

There are different 'bands' for the weight (i.e. between 150g and 200g the
price is 0.50). What's the best way to write a statement for this ? I have
tried different ways of writing an If statement but they all end up in
chaos.

John


 
Reply With Quote
 
 
 
 
Aaron Bertrand - MVP
Guest
Posts: n/a
 
      07-10-2003
Use a database table. Assuming SQL Server:



CREATE TABLE postageRates
(
weightlowerbound INT,
weightupperbound INT,
rate DECIMAL(19,2)
)

INSERT postageRates VALUES(0, 149, 0.25)
INSERT postageRates VALUES(150, 200, 0.50)
INSERT postageRates VALUES(201, 500, 0.85)
-- ...

DECLARE @weight INT
SET @weight = 172
SELECT rate FROM postageRates
WHERE @weight
BETWEEN weightlowerbound AND weightupperbound

DROP TABLE postageRates



You could also do this within an array in ASP...



"John Smith" <(E-Mail Removed)> wrote in message
news:beken4$pi4$(E-Mail Removed)...
> Hi,
>
> I'm trying to work out the postage rate for products in a shopping cart.
> Predictably there is no formula for working out the postage rate (ie. 0.20

*
> weight). The problem i'm having is with the statement for working this out
>
> There are different 'bands' for the weight (i.e. between 150g and 200g the
> price is 0.50). What's the best way to write a statement for this ? I have
> tried different ways of writing an If statement but they all end up in
> chaos.
>
> John
>
>



 
Reply With Quote
 
 
 
 
John Smith
Guest
Posts: n/a
 
      07-10-2003
works great, thanks !


"Aaron Bertrand - MVP" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Use a database table. Assuming SQL Server:
>
>
>
> CREATE TABLE postageRates
> (
> weightlowerbound INT,
> weightupperbound INT,
> rate DECIMAL(19,2)
> )
>
> INSERT postageRates VALUES(0, 149, 0.25)
> INSERT postageRates VALUES(150, 200, 0.50)
> INSERT postageRates VALUES(201, 500, 0.85)
> -- ...
>
> DECLARE @weight INT
> SET @weight = 172
> SELECT rate FROM postageRates
> WHERE @weight
> BETWEEN weightlowerbound AND weightupperbound
>
> DROP TABLE postageRates
>
>
>
> You could also do this within an array in ASP...
>
>
>
> "John Smith" <(E-Mail Removed)> wrote in message
> news:beken4$pi4$(E-Mail Removed)...
> > Hi,
> >
> > I'm trying to work out the postage rate for products in a shopping cart.
> > Predictably there is no formula for working out the postage rate (ie.

0.20
> *
> > weight). The problem i'm having is with the statement for working this

out
> >
> > There are different 'bands' for the weight (i.e. between 150g and 200g

the
> > price is 0.50). What's the best way to write a statement for this ? I

have
> > tried different ways of writing an If statement but they all end up in
> > chaos.
> >
> > John
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl Shopping Cart Scripts GeorgeF Perl 1 05-22-2005 04:41 AM
Shopping Cart - database vs session Paul Hobbs ASP .Net 2 12-04-2003 08:35 PM
OT: Shopping cart reccomendations John ASP .Net 1 11-07-2003 05:16 PM
Shopping Cart Component Suggestions Mark Fox ASP .Net 1 11-04-2003 10:02 AM
Secure shopping cart example? Bruce W...1 ASP .Net 3 08-27-2003 06:48 PM



Advertisments