Le 2013-02-14 à 07:52, Maik Musall <[email protected]> a écrit :
> > Am 14.02.2013 um 13:38 schrieb Pascal Robert <[email protected]>: > >> Hi guys, >> >> In a shopping cart, how would you apply discount based on business rules? >> For example, if someone buy a quantity of 3 of the same item, you apply >> discount X, or if an item is ordered before a certain date, you apply >> discount Y. Yes, I can do that all in code, but that's not very flexible. >> >> Any ideas? > > Add an abstraction layer for shopping cart items and add virtual items to the > cart that contain the calculated rebate? If I understand well, let's say I have "item.quantity()" with a value of 2. I then would have another EO related to this item for each quantity that a discount should be applied to. For example, item's name is "WOWODC 2013 ticket" and someone wants to buy two tickets. In "VirtualItem", I would have multiple rows for "WOWODC 2013 ticket", with a different quantity and discount for each row, so I would do a fetch « VirtualItem.NAME.eq("WOWODC 2013 ticket").and(VirtualItem.QUANTITY(2) » and apply the discount from the fetched row. (this is just an example, I wouldn't do the qualifier on the name of the product, it will be a relationship instead). _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
