[ic] Promo pricing

Nicholas Cook interchange-users@icdevgroup.org
Mon Apr 7 07:55:02 2003


Thanks,
Works perfectly.

Nicholas Cook

Mike Heins wrote:
> Quoting Nicholas Cook (ncook@foxmillpets.com):
> 
>>I'm currently using 4.9.6 and I am trying to figure out how to set a new 
>>price for a product for the duration of a promo.  After the promo 
>>expires, I want the price to go back it's regular price.
> 
> 
> This is pretty easy to do with a custom pricing tag. I don't put this
> in standard because it can impact performance.
> 
> UserTag promo_price Routine <<EOR
> sub {
> 	# $item is already set as part of pricing routines
> 	my $mhash = tag_data( 'merchandising', undef, $item->{code}, { hash => 1 })
> 		or return;
> 	return unless $mhash->{timed_promotion};
> 	my $currtime = POSIX::strftime('%Y%m%d%H%M%S', localtime());
> 
> 	return unless $mhash->{start_date} lt $currtime;
> 	return unless $mhash->{finish_date} gt $currtime;
> 	my $base = $item->{mv_ib} || 'products';
> 	return tag_data($base, 'sale_price', $item->{code});
> }
> EOR
> 
> (That is a *global* UserTag.)
> 
> Then this CommonAdjust:
> 
> 	CommonAdjust   [promo-price], ;:price
> 
> will implement it.
> 
> You can get better performance with:
> 
> 	AutoModifier   merchandising:timed_promotion
> 	CommonAdjust   [promo-price], ;:price
> 
> UserTag promo_price Routine <<EOR
> sub {
> 	# $item is already set as part of pricing routines
> 	return unless $item->{timed_promotion};
> 	my $mhash = tag_data( 'merchandising', undef, $item->{code}, { hash => 1 })
> 		or return;
> 	my $currtime = POSIX::strftime('%Y%m%d%H%M%S', localtime());
> 
> 	return unless $mhash->{finish_date} gt $currtime;
> 	return unless $mhash->{start_date} lt $currtime;
> 	my $base = $item->{mv_ib} || 'products';
> 	return tag_data($base, 'sale_price', $item->{code});
> }
> EOR
>