You don't work for Old Navy do you? My wife just bought to shirts that were on sale, 2 for $10, but she didn't get the discount because they were different sizes! :)
Okay, so you know the quantity for each SKU, right? And given a SKU (1007.blu.sm), you know it's product number (1007). So you can have one function that, given the product number, loops over all the items in the cart and tallies up the total number of products that match a product number. Now that you have a true total, you can look up the price per item, and return that price. To calculate the price for a given item, you find the product number and call the above function to get the correct price. To make it work right, you would need to recalculate the prices for every item in the cart every time the cart changes. I hope this helps. There are all sorts of inefficiencies in this scheme, but I trust once you get it working, you'll figure out divide the responsibilities into smaller functions/objects and cut out the unnecessary work. Patrick On 11/23/06, Will Tomlinson <[EMAIL PROTECTED]> wrote: > Hey, > > I have a doozy cart requirement that has arisen. > > My cart needs the ability to apply qty discounts for a given product. With my > prods, I have different SKU's listed for a given prod. i.e. Prod 1007 might > have a blu sm, blu med, blu lg, each with its own SKU, etc. > > I built a quick'n'dirty version that works but it isn't perfect. I just > linked up a qty range table to tblProducts. It includes a price for a qty > range that can be applied to a product. It works, but it only works for a > single sku, because the cart isn't smart'nuff to know that other skus add up > to create a total qty for a product. Hope this is makin sense. lol! > > Anyway, the end problem is as it stands now, the cart can't keep track of > qty's for a product. Just qty's for an individual SKU. > Example: > All Prod 1007 skus might be $55.00. Prod 1007's qty ranges might be: > 10-20 = $50.00. > 21-30 = $45.00 > > If someone adds 15 of the 1007.BLU.SM , the cart says it's $50.00 each. Fine, > no problem. > Then they add 10 of the 1007.BLU.MD, the cart says those are $50.00 each. > OOPS! The cart doesn't know that we have another qty of the same product > already there. It should be $45.00 each now, since all told, we now have 25 > items for this product in the cart, which should get a price of $45.00 each. > it can only keep track of the individual SKUS. If we had added 25 of the same > item from the start, it woulda calculated things correctly. > > The cart should be able to calculate up each prod ID's qty's. Then it should > query the DB table and get the price for whatever price range the total falls > into. It basically should be able to keep track of a prod's total qty's at > any given time. > > Am I thinking right? How would YOU do it? Do you create applyQTYDiscount()? > Call it, it works its magic, loops over the cart struct, applying the new > updated discount prices for every cart item? > > Thanks much! > Will > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:261613 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

