[ic] Complex pricing
mike at perusion.com
Mon Jul 19 05:14:04 EDT 2004
Quoting Daniel Davenport (ddavenport at newagedigital.com.org):
> One of our clients has products with lots of options (sometimes 15-20 per
> product). They want to be able to edit the pricing formulas whenever they
> change, which apparently is somewhat often....but they don't know much about
> perl and know even less about Interchange, so hard-coding formulas in a
> UserTag is pretty much out of the question. To complicate things further,
> they have some options which depend on the values of other options (mostly
> size), but others are simple, standalone options. Using matrix options for
> everything would create tens of thousands of variants for each item at
> least, not to mention making it several people's full-time job just changing
> prices. :)
> In the solution i'm working on, pieces of the formulas are in their own
> table, and a couple of UserTags look up the parts of the formula, assemble
> them into a CommonAdjust string, and return the string. According to my
> understanding of the IC docs, that string should be parsed and used.
> However, it seems that Interchange is only paying attention to the first
> atom in the string. (When i tell the main UserTag to always return
> '50.00, -20.00' as a test, the price ends up being 50.00 (minus
> wholesale/dealer/etc pricing, which is from the main CommonAdjust string and
> seems to work fine).
You can only return a string of atoms in the database field that is
the source for the CommonAdjust string.
> The only way i can think of for returning a whole CommonAdjust string is
> having a table of temporary strings and returning a lookup atom that points
> to the string. Depending on how IC handles anything besides a price or
> percentage, it might work or it might not...but even if it did work, i'd be
> asking for trouble. Please tell me there's a less contorted, less
> error-prone way.
I don't think we can easily cause atoms to be inserted in the current
stack of CommonAdjust atoms. It would certainly be possible to totally
*replace* the current stack of atoms with a new series of atoms that
were generated from a UserTag, but that would remove your subsequent
items that you are using.
But wait a minute -- can't you just do in a Global::UserTag:
UserTag test-common-adjust Routine <<EOR
my $string = '50.00, -20.00';
# $item is set before calling the UserTag
my $cost = Vend::Data::chain_cost($item, $string);
Yes, that works.
Perusion -- Expert Interchange Consulting http://www.perusion.com/
phone +1.765.647.1295 tollfree 800-949-1889 <mike at perusion.com>
Being against torture ought to be sort of a bipartisan thing.
-- Karl Lehenbauer
More information about the interchange-users