Positional parameters in same order.
Pass attribute hash as last to subroutine: no
Must pass named parameter interpolate=1 to cause interpolation.
This is a container tag, i.e. [discount] FOO [/discount]. Nesting: NO
Invalidates cache: YES
Called Routine:
ASP/perl tag calls:
$Tag->discount( { code => VALUE, }, BODY ) OR $Tag->discount($code, $BODY);
1. A discount for one particular item code (code/key is the item-code) 2. A discount applying to all item codes (code/key is ALL_ITEMS) 3. A discount applied after all items are totaled (code/key is ENTIRE_ORDER)
The discounts are specified via a formula. The formula is scanned for the
variables $q
and $s, which are substituted for with the item
quantity and subtotal respectively. In the case of the item and all items discount, the formula
must evaluate to a new subtotal for all items of that code that are ordered. The discount for the entire order is applied to the
entire order, and would normally be a monetary amount to subtract or a flat
percentage discount.
Discounts are applied to the effective price of the product, including any quantity discounts.
To apply a straight 20% discount to all items:
[discount ALL_ITEMS] $s * .8 [/discount]
or with named attributes:
[discount code=ALL_ITEMS] $s * .8 [/discount]
To take 25% off of only item 00-342:
[discount 00-342] $s * .75 [/discount]
To subtract $5.00 from the customer's order:
[discount ENTIRE_ORDER] $s - 5 [/discount]
To reset a discount, set it to the empty string:
[discount ALL_ITEMS][/discount]
Perl code can be used to apply the discounts. Here is an example of a discount for item code 00-343 which prices the second one ordered at 1 cent:
[discount 00-343] return $s if $q == 1; my $p = $s/$q; my $t = ($q - 1) * $p; $t .= 0.01; return $t; [/discount]
If you want to display the discount amount, use the [item-discount] tag.
[item-list] Discount for [item-code]: [item-discount] [/item-list]
Finally, if you want to display the discounted subtotal in a way that doesn't correspond to a standard MiniVend tag, you can use the [calc] tag:
[item-list] Discounted subtotal for [item-code]: [currency][calc] [item-price noformat] * [item-quantity] [/calc][/currency] [/item-list]
%% dump %% Prints a dump of the current user session as expanded by Data::Dumper. Includes any CGI environment passed from the server.
%% either %% The [either]this[or]that[/either]
implements a check for the first non-zero, non-blank value. It splits on
[or], and then parses each piece in turn. If a value returns true (in the
Perl sense -- non-zero, non-blank) then subsequent pieces will be discarded
without interpolation.
Example:
[either][value must_be_here][or][bounce href="[area incomplete]"][/either]