[ic] Discount Question

Mike Heins mike at perusion.com
Wed Jul 21 18:00:18 UTC 2010


Quoting Stefan Hornburg (Racke) (racke at linuxia.de):
> On 07/21/2010 03:37 PM, Mike Heins wrote:
> >Quoting Stefan Hornburg (Racke) (racke at linuxia.de):
> >>On 07/11/2008 05:16 PM, Stefan Hornburg (Racke) wrote:
> >>>Ton Verhagen wrote:
> >>>>Quoting Stefan Hornburg:
> >>>>At 04:36 PM 7/3/2008, you wrote:
> >>>>>Hello,
> >>>>>
> >>>>>I'm working on a pretty simple discounting scheme for a client: 10% off
> >>>>>for every order with a subtotal>= 100$. This should be very easy to
> >>>>>implement.
> >>>>>
> >>>>>Let's try that:
> >>>>>
> >>>>>[tmp total][subtotal noformat=1][/tmp]
> >>>>>[if type=explicit compare=`$Scratch->{total}>= 100`]
> >>>>>[discount ALL_ITEMS]
> >>>>>$s * 0.9
> >>>>>[/discount]
> >>>>>[else]
> >>>>>[discount ALL_ITEMS][/discount]
> >>>>>[/else]
> >>>>>[/if]
> >>>>>
> >>>>>OK, but here are the problems:
> >>>>>
> >>>>>[subtotal] has existing discounts already applied if I understand the
> >>>>>source code correctly, so change the above to:
> >>>>>
> >>>>>[discount ALL_ITEMS][/discount]
> >>>>>[tmp total][subtotal noformat=1][/tmp]
> >>>>>[if type=explicit compare=`$Scratch->{total}>= 100`]
> >>>>>DISCOUNT for [scratch total]
> >>>>>[discount ALL_ITEMS]
> >>>>>$s * 0.9
> >>>>>[/discount]
> >>>>>[/if]
> >>>>>
> >>>>>That should be fine. Now my client want to display [subtotal] with
> >>>>>out a discount and the discount on the order.
> >>>>>
> >>>>>Duh ..
> >>>>>
> >>>>>What about introducing [subtotal nodiscount=1] ?
> >>>>
> >>>>
> >>>>Would be a wonderful solution IMHO.
> >>>
> >>>OK, I'll implement that in the next few days.
> >>
> >>Time flies by ... but now we got [subtotal nodiscount=1] in Git.
> >>
> >>I really don't like how we lump subtotal and discount calculation together
> >>in Vend::Interpolate::subtotal.
> >>And why we save the subtotal into the session as latest_subtotal really
> >>eludes me.
> >
> >Because subtotal calculations can be very computationally expensive.
> 
> I agree with you that repeating price calculations (especially during
> a page run) isn't a good idea. With a better model inside Interchange,
> we could cache all that results inside the cart or a similar entity.

Ah yes, hindsight.

> So first time during a page run, subtotal computes prices and subtotal
> and the second time you get it from the cache.
> 
> Using a session variable that is undocumented and unused in the demo
> is IMHO the wrong approach. Why should the catalog developer care
> about that?

It wasn't undocumented at one time.

> 
> >
> >>I'm looking forward to remove this.
> >
> >It will break catalogs all over the place.
> >
> 
> Not any of mine. I'm working hard to reducing the impact of Interchange
> on my catalogs. :-).
> 
> In the given situation: should I refrain from altering latest_subtotal
> on [subtotal discount=1].

I would say that we should make latest_subtotal be the all-inclusive 
subtotal, so yes. (Assuming you mean nodiscount=1).

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.765.328.4479  <mike at perusion.com>

The sun, with all those planets revolving around it and dependent on it,
can still ripen a bunch of grapes as if it had nothing else in the
universe to do. -- Galileo



More information about the interchange-users mailing list