sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
John Smith's Avatar

shopping cart


Question posted by: John Smith (Guest) on July 19th, 2005 06:35 AM
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


2 Answers Posted
Aaron Bertrand - MVP's Avatar
Aaron Bertrand - MVP July 19th, 2005 06:35 AM
Guest - n/a Posts
#2: Re: shopping cart

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" <john@nospam.spam> wrote in message
news:beken4$pi4$1@titan.btinternet.com...[color=blue]
> 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[/color]
*[color=blue]
> 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
>
>[/color]


John Smith's Avatar
Guest - n/a Posts
#3: Re: shopping cart

works great, thanks !


"Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
news:%23Kt3stxRDHA.3192@TK2MSFTNGP10.phx.gbl...[color=blue]
> 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" <john@nospam.spam> wrote in message
> news:beken4$pi4$1@titan.btinternet.com...[color=green]
> > 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.[/color][/color]
0.20[color=blue]
> *[color=green]
> > weight). The problem i'm having is with the statement for working this[/color][/color]
out[color=blue][color=green]
> >
> > There are different 'bands' for the weight (i.e. between 150g and 200g[/color][/color]
the[color=blue][color=green]
> > price is 0.50). What's the best way to write a statement for this ? I[/color][/color]
have[color=blue][color=green]
> > tried different ways of writing an If statement but they all end up in
> > chaos.
> >
> > John
> >
> >[/color]
>
>[/color]


 
Not the answer you were looking for? Post your question . . .
197,031 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 197,031 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors