[ic] IC 4.6.3 Item Discounts

Russ Mann tech@khouse.org
Wed, 21 Mar 2001 15:02:10 -0700


I'm trying to implement a certain type of discount in IC 4.6.3.

I have some products which are BPS which get discounted at a rate of 2.70
off each from 3-9, and 3.20 off from 10+.

This is the code that I use to determine and set the discounts:

[calc]$totalbps=0; $Scratch->{totalbps} = "$totalbps";[/calc]
[item-list][if-field quantitydiscount][calc]$totalbps +=
[calc]$Scratch->{totalbps} = "$totalbps" if $totalbps;[/calc]

[perl arg=scratch interpolate=1]
my $numoff;
my $totalbps = $Safe{'scratch'}->{'totalbps'};
if ($totalbps <= 2) { $numoff = 0; }
elsif (($totalbps >= 3) && ($totalbps <=9)) { $numoff = 2.70; }
elsif ($totalbps >= 10) { $numoff = 3.20; }
$discount_amount = $totalbps * $numoff;
$Safe{'scratch'}->{'discount_amount'} = $discount_amount;
$Safe{'scratch'}->{'numoff'} = $numoff;
return '';

[calc]$discount_amount = [scratch discount_amount][/calc]
[calc]$numoff = [scratch numoff][/calc]

[item-list][discount [item-code]][/discount][/item-list]

[if-field quantitydiscount]
[if scratch numoff]
[calc][discount [item-code]] return ($s - ($q*$numoff)) [/discount][/calc]

In the cart, this works:

[if discount [item-code]]
<td align=right>
<td align=right>
<td align=right>
<td align=right>

However, in the mail_receipt (in /etc) this does NOT work:

[if discount [item-code]]
[column width=9 align=right gutter=1][currency][calc][item-discount-subtotal
[column width=11 align=right gutter=1][item-discount-subtotal][/column]
[else][column width=9 align=right gutter=1][item-price][/column]
[column width=11 align=right gutter=1][item-subtotal][/column][/else]

This is the error I receive:

[21/March/2001:13:50:24 -0800] catalog /store/catalog/process.html Safe:
Can't modify subtraction in scalar assignment at (eval 317) line 1, near
> [item-discount-subtotal noformat=1]/[item-quantity]

I can't use the [discount-price] tag because it returns
[item-price]-[item-difference], which isn't what I need.

Any assistance would be greatly appreciated.



Just Over the Pond - Rekindling the Grace of Life.
Visit the online store for gourmet teas and gift ideas!