[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] Re: CommonAdjust calculated price
- Subject: [ic] Re: CommonAdjust calculated price
- From: interchange-users@icdevgroup.org (Daniel A. Shockley)
- Date: Mon Nov 11 12:10:00 2002
- In-reply-to: <20021109170001.3029.46824.Mailman@plain.rackshack.net>
- References: <20021109170001.3029.46824.Mailman@plain.rackshack.net>
Well, I'm now getting $0 for all of my prices.
I even tried a simple test UserTag that just returns 1.23, and that
also gives $0.00 for all prices. I disabled after.cfg, so it doesn't
change my CommonAdjust. Is there something else interfering that I
don't know about? I'm running Interchange on a host that provides it
through CPanel, if that makes a differences.
In catalog.cfg (the UserTag should be fine there, right? Am I crazy?):
PriceField 0
CommonAdjust [insc_price]
UserTag insc_price Order code quantity inscription
UserTag insc_price Routine <<EOR
sub {
my ($sku, $quantity, $inscription) = @_;
$sku ||= $item->{code};
$quantity ||= $item->{quantity};
$inscription ||= $item->{inscription};
my $price = $Tag->data( {
table => 'products',
field => 'price',
key => $sku,
});
return $price*$quantity + $quantity*1.50*length($inscription);
}
EOR
>Quoting Daniel A. Shockley (danielashockley@yahoo.com):
>> > > I can see how to have CommonAdjust lookup a static price for an Option,
>> >> but the price is based on the LENGTH of what was typed in, not on an
>> >> option chosen from a Select popup. I can calculate the additional price
> > >> using perl, of course, but how do I get CommonAdjust to see that price?
Mike Heins wrote:
>I don't know if $item is in scope in that code, quite frankly. But
>it would be in the usertag, so just do:
>
>CommonAdjust [insc-price]
>
>UserTag insc_price Interpolate
>UserTag insc_price Order code quantity inscription
>UserTag insc_price Routine <<EOR
>sub {
> my ($sku, $quantity, $inscription) = @_;
>
> $sku ||= $item->{code};
> $quantity ||= $item->{quantity};
> $inscription ||= $item->{inscription};
>
> my $price = $Tag->data( {
> table => 'products',
> field => 'price',
> key => $sku,
> });
>
> return $quantity*($price + $quantity * 1.50 * length($inscription));
>}
>EOR
Kevin Walsh wrote:
>As a side note, you may want to strip any leading/trailing whitespace
>before calling "length($inscription)" to calculate the price.
>
>You should also think about making the "1.50" value configurable,
>perhaps using a Variable in catalog.cfg or your variable table.
>It could be difficult to remember where that price is set if you
>wanted to change it in the future. I assume the 1.50 price is fixed,
>regardless of the item being inscribed.
>
>One last point - remove that "Interpolate" setting - you don't need it.
Thanks for the suggestions - I'll probably do all that once I have it working.
--
----
Daniel A. Shockley, Database Programmer
MacEasy Computing
DanielAShockley@yahoo.com
dan@maceasycomputing.com
http://www.maceasycomputing.com