473,396 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

shopping cart

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
Jul 19 '05 #1
2 2154
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" <jo**@nospam.spam> wrote in message
news:be**********@titan.btinternet.com...
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

Jul 19 '05 #2
works great, thanks !
"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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" <jo**@nospam.spam> wrote in message
news:be**********@titan.btinternet.com...
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


Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Don Grover | last post by:
I am retrieving costs and product id's from a sql db. and need to build a shopping cart around it. How do I store the selected items and qty req so I can move into another catalog and total up as...
2
by: Paul Bruneau | last post by:
Hi, I hope someone can help me make a working shopping cart, as a learning tool. If I have a "Product Demo" html page with a "Buy Me" button, there must be a simple javascript method of...
1
by: madison | last post by:
Hi, I am trying to start a website using paypals shopping cart function. If i have 10 items and they sell out, how do I make it so the item is then listed as sold out. The next person would not...
1
by: Jia Sun | last post by:
hello , everybody , i need a similar program , just like fancyimport.com if possible, pls contact me ,thank you very much . inchina@gmail.com
1
by: Adil Akram | last post by:
I have created a site shopping cart in ASP.net. I am using ASP session object's SessionID on non SSL connection to track session. While adding products to cart DB I insert product and SessionID...
2
by: G.E.M.P | last post by:
High Level Session Handling Design for a Shopping cart 0) What am I missing? 1) How does OSCommerce do it? I'm thinking about building a shopping cart from scratch, using a library of dynamic...
7
by: isaac2004 | last post by:
hi i have a basic asp page that acts as an online bookstore. on my cart page i am having trouble generating 3 numbers; a subtotal, a shipping total, and a final price. here is my code i would...
1
by: jecha | last post by:
I'm implementing a shopping cart but am having a problem in checking out a person who has added item in his/her shopping busket.The code for the checkout.php script is given below <?...
15
gregerly
by: gregerly | last post by:
Hello, I once again turn to this community of genius' for some help with a problem. I've got a shopping cart (which is working well so far) that I will be implementing all kinds of AJAX...
3
by: Paulo | last post by:
Hi, beginner on asp.net 2.0 C# VS 2005, how can I use the shopping cart concept on my application? When the user clicks add item, it will be stored on some storage format, I dont know what is the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.