[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Re: custom pricing routines using [perl] and [discount]
Tim,
Check out this old archived list message:
http://www.minivend.com:80/minivend/minivend-list/1999/msg01524.html
It was the inspiration for the following
UserTag arrangement that will calculate prices
on the fly. Note: I'm simplifying, so a syntax
error might creep in.
Thanks to Mike Heins for posting the code in
the first place.
##
## This works in catalog.cfg because Vend::Session and Vend::Interpolate
## are exempted from Safe checking in UserTags
##
UserTag check-breaks Routine <<EOR
sub {
my $price;
my $q = $Vend::Interpolate::item->{quantity};
# do a different if statement for each item with
# odd pricing requirements
if ($Vend::Interpolate::item->code eq 'MMS-0120')
{
#set the price for quantity 1
if ($q == 1)
{
$price=15;
}
#set the price for qty 2 through 5
if ($q > 1 and $q <=5)
{
$price=10;
}
#report the calculated per-item pricing
return $price;
}
#if this isn't a special item, continue pricing
# using CommonAdjust
return;
}
EOR
Then, also in catalog.cfg:
# tag touch prepares for use of tag_data, not really needed for
# SQL or memory databases
CommonAdjust "[tag touch products][/tag][check-breaks]", ;products:price