For more information... RTFM!
NAVIGATION
PAGES THAT LINK HERE
ACCOUNT LOGIN

You are not logged in

Powered by Interchange version 5.7.0

discount

Set or clear product price discounts.

Summary

  • [discount code] Discount rules [/discount]

Parameter Description Default
code The product's SKU code or one of either "ALL_ITEMS" or "ENTIRE_ORDER". None
discount_space Select the discount namespace to use. main
space Alias for discount_space. main
interpolate Parse Interchange tags, included in the body text, before this container tag executes. No

Examples

Perl example

$Tag->discount({
    code => $sku,
    body => $body,
});

or similarly with positional parameters:

$Tag->discount($sku, $attribute_hash_reference, $body);

Description

Product discounts can be set upon display of any page.  The discounts apply only to the customer receiving them and may be of one of three types:

  1. A discount for one particular item code (code/key is the item's SKU code)
  2. A discount applying to all item codes (code/key is ALL_ITEMS)
  3. A discount applied after all items are totalled (code/key is ENTIRE_ORDER)

The discounts are specified using 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 SKU 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 a named, rather than a positional, parameter:

[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, just set it to an empty string, like this:

[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 discounted subtotal in a way that doesn't correspond to a standard Interchange tag then you can use the [calc] tag.  (well, [item-calc] in this example):

[item-list]
    Discounted subtotal for [item-code]: [item-filter currency][item-calc]
        [item-discount noformat=1] * [item-quantity]
    [/item-calc][/item-filter]<br>
[/item-list]

Here is a slightly more complicated example that gives a 10% discount if a product is ordered with a quantity of two or more, with a further 5% discount for each additional item, up to a maximum discount of 30% per SKU code.

[discount ALL_ITEMS]
    return $s if $q == 1;
    return $s * .70 if $q > 6;
    return $s * (1 - (0.05 * $q));
[/discount]

Parameters

code

The product SKU code or one of either ALL_ITEMS or ENTIRE_ORDER.

discount_space

Select the discount namespace to use when DiscountSpacesOn mode is in operation.  The default discount namespace is "main".  Also see the [discount-space] tag and the DiscountSpaceVar local configuration directive.

Availability

Availability

This parameter was introduced in version 5.4.0, and is therefore not available for use with any earlier Interchange version.

Category:  Interchange tags
Last modified by: Kevin Walsh
Modification date: Monday 2 July 2007 at 12:15 PM (CDT)
Home  |  Legal nonsense  |  Privacy policy  |  Donations  |  Contact us