Title: Message

Jim,

 

Maybe if I run through how we set it up you might get some ideas. Before I start this is how our ERP is designed and would certainly be overkill for a simple shopping cart. It will hopefully give you some ideas on how to build a robust discounting system though.

 

First off we broke discounts into two types.

 

1.Whole of order – applies to order total

2.Product line – applies to each product only

 

For whole of order discounts our process runs like this.

 

Our system uses events to handle orders as they have a distinct lifecycle ie, open, amend, processDiscount, processInvoice, etc. We have a manager object which handles order objects but also retrieves discount and tax types. After a user has completed an order we have an order object sitting in the manager. To apply a discount we trigger a discount event on the order as follows:

 

- shoppingCartManager.getDiscountType() –  Returns a discount object based on myOrder.discountContext (property of order). This is where you could supply a coupon number.

- shoppingCartManager.myOrder.processDiscountEvent(discountObject) – creates a discount event in the order object with discount object

- myOrder.discountEvent.discount.calculateDiscountedPrice(totalPrice) – this is a call to the discount object to calculate and return the discount on the order total.  

                                                           

The beauty of this is that we can apply multiple discounts to an order total by stacking them in discountEvent.

 

 

Now for product lines we don’t calculate discounts on an order line. Instead we use product/package pricing. Meaning we don’t associate discounts with an orderline but with a product itself. So here are the steps with this.

 

- Get precondition which could be customer, order quantity, coupon number.

- orderline[n].product.getPrice(preconditions) – on each order line we have a product object which is responsible for it’s own pricing. We use rule sets and catalogues to filter prices on preconditions passed in. It would take me a day to fully explain what goes on here but you could build some pretty simple rules here like ‘buy 6 get 1 free’. Even with a simple application you can quickly build up a set of rules. The point here is that your rule is tied to the product rather than the order.

 

Bottom line is to correctly define your discount type before you start. Does it apply to the whole order or a product? What are the conditions that must be met before the discount can be given? If there is more than one discount in what order are they applied?

 

This is pretty full on for a simple shopping cart hey? Anyway, food for thought J

 

Angus

 

 

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jim McMullen
Sent: Thursday, 24 March 2005 12:58 AM
To: [email protected]
Subject: [CFCDev] Help with OO Model for Shopping Cart

 

I have a typical CFC-based shopping cart (ShoppingCart object holds a struct of CartItem objects). This works well and I have no real problem with it.

 

However, I now need to implement a pretty robust coupon/discount functionality into the app, and I can't seem to figure out how to do it. I need to allow for four types of coupons:

 

(1) Whole order coupon (NN% off entire order)

(2) Single item coupon (NN% off this item)

(3) Multiple item coupon (buy one (or two), get the 2nd (or third) NN% off)

(4) Free item coupon (buy this item, get a free toaster)

 

I think I can figure out how to model a single coupon type, but as I'm an OOP newb, figuring out how to model and implement the whole range has got my head spinning.

 

Can anyone point me in the right direction?

 

Jim McMullen

Devlab, Inc.

---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). An archive of the CFCDev list is available at www.mail-archive.com/[email protected] ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). An archive of the CFCDev list is available at www.mail-archive.com/[email protected]

Reply via email to