[ic] Discounts and coupons and CommonAdjust and...eh.
dances_with_peons at live.com
Tue Nov 16 21:45:24 UTC 2010
One of my clients’ site is running in IC v5.6.2, and currently has rather
simple "coupons" using discounts. A coupons table contains info about each
coupon, valid dates, amount or percentage off, etc. When the user inputs a
coupon code, the checkout page (with the help of a usertag) looks up a
coupon, sets the discount, and done. This setup has been in the store for a
while now, and has worked to some degree, as the coupons tend to be a
percentage, and either apply to ALL_ITEMS or are for all of a specific item.
They're outgrowing this simplistic setup, though, and are now asking for
By "real" coupons, I mean (among other things):
* A coupon can apply to a single item in the cart, or to some other
per-coupon limit on item count. That is, if I have a coupon for $5 off item
203, it can just deduct $5 from the first 203 in the cart, and leave the
rest alone. Even if they're on separate lines.
* Multiple coupon codes can be added to the order for a sku. That is, if I
have a coupon for a free item 123, and another coupon for 20% off item 123,
* If a coupon is removed, or certain order data changes (like the ship date,
or the zip code), the coupon would not apply. In those cases, the discount
needs to be removed. The flypage, cart page, and checkout all need to
forget whatever discounts are no longer valid, but keep track of the
discount in case the order changes to make it valid again.
* The coupon discounts the price, but leaves the pre-coupons price available
(so one can see how much they saved).
The existing, discount-based solution runs smack into the first two
problems; the discount ends up applying to every item 203 in the cart, and
it ends up overwriting other discounts for the same sku. I managed to get
around the third problem by adding some code with Pragma init_page, that
looks through the coupon codes and reapplies all the discounts that are
still valid, but it feels like an ugly hack -- and still doesn't solve the
real problems. I need to come up with a better way.
I looked at CommonAdjust, but it has one major problem when it comes to
coupons: the discounted price becomes the "price", meaning all the code I
currently have in the cart and checkout that says "this item is discounted"
no longer works. This is a particularly big problem because there's
existing CommonAdjust stuff that prices the item by area and order date and
delivery date, so simply looking at the "price" field won't work. (There
are actually a couple of price fields, so it'd be a bit of a pain to look up
My hopelessly optimistic question: Is there some decent built-in coupon
stuff that I've been overlooking all this time? Preferably something that
can be extended, cause the client has some freakishly complicated things
they want to do with coupons. Ideally, it should also be able to separate
"price" from "price with coupon", like the discount stuff and
[item-discount*] manage to do.
Failing that, we have my real question: What's the best way to do all this
without having to replace/replicate/rewrite half the pricing stuff in IC?
More information about the interchange-users