Re: IDEA: Method for Shopping Cart QUANTITY DISCOUNT?

From: Date: Wed, 22 Nov 2000 20:08:05 +0000
Subject: Re: IDEA: Method for Shopping Cart QUANTITY DISCOUNT?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-26697@lists.php.net to get a copy of this message
Ideally, you'd have a whole separate function/module/something to handle discounts. The kludgy way would be to set up large blocks of IF conditions and change your 'total' or 'unit price' accordingly. if ($numwidgets == 2) { $eachWidgetPrice = $9; } if ($numwidgets == 3) { $eachWidgetPrice = $8.50; } etc. If you know that this is a mathmatical forumula, you could set it up as such, but it may not be. Having a completely separate module that gets included will make it much easier for readability. You can also set up other conditions: if ($numWidgets >3) { if (date="Thursday") { $shipping = free; } } and so on. Kludgy? Yes, but it'd work. More elegant way would be to set up a rule system for determining conditions which need to be met for particular triggers. Kinda lengthy to go into here, and I'm sure others will post ideas that are equally (or moreso!) useful. Derek Sivers wrote: > I know LOTS of us on the PHP list have worked with shopping carts. > > Has anyone found a good solution/method for doing quantity discounts? > > 1 widget = $10 > 2 widgets = $18 > 3 widgets = $27.50 > 4 widgets = $35.33 > 5 widgets = $40.00 > each additional = $5 > > Do you make SEPARATE ITEMS like a bundle? > Like "widget1" is an item at $10 but > "widget2" is a single item, costing $18? > (And if so, do you scroll through and decrease inventory of sub-items > inside the "widget2" package item?) > > I'd be doing this for a store with over 10,000 items, so it'd have to be > easily scalable. > > Any ideas, anyone? > ========================== Michael Kimsal PHP Meta search http://www.phphelpdsk.com/search/ PHP Training courses http://www.tapinternet.com/php

« previous php.general (#26697) next »