4.54. price

4.54.1. Summary

Parameters: code

Positional parameters in same order.

The attribute hash reference is passed to the subroutine after the parameters as the last argument. This may mean that there are parameters not shown here.

Must pass named parameter interpolate=1 to cause interpolation.

Invalidates cache: no

Called Routine:

ASP-like Perl call:

         code => VALUE,


    $Tag->price($code, $ATTRHASH);

Attribute aliases

            base ==> mv_ib
    [price code other_named_attributes]
Parameters Description Default
base Alias for mv_ib DEFAULT_VALUE
Attributes Default
interpolate (reparse) No
Invalidates cache no
Container tag No
Has Subtags No
Nests Yes

Tag expansion example:

    [price code]
    TODO: (tag result)

ASP-like Perl call:

   $Tag->price(  { code => VALUE_code
}, $body  );

or similarly with positional parameters,

    $Tag->price(code, $attribute_hash_reference, $body);

4.54.2. Description


        code       Product code/SKU
        base       Only search in product table *base*
        quantity   Price for a quantity
        discount   If true(1), check discount coupons and apply
        noformat   If true(1), don't apply currency formatting

Expands into the price of the product identified by code as found in the products database. If there is more than one products file defined, they will be searched in order unless constrained by the optional argument base. The optional argument quantity selects an entry from the quantity price list. To receive a raw number, with no currency formatting, use the option noformat=1.

Interchange maintains a price in its database for every product. The price field is the one required field in the product database -- it is necessary to build the price routines.

For speed, Interchange builds the code that is used to determine a product's price at catalog configuration time. If you choose to change a directive that affects product pricing you must reconfigure the catalog.

Quantity price breaks are configured by means of the CommonAdjust directive. There are a number of CommonAdjust recipes which can be used; the standard example in the demo calls for a separate pricing table called pricing. Observe the following:

   CommonAdjust  pricing:q2,q5,q10,q25, ;products:price, ==size:pricing

This says to check quantity and find the applicable column in the pricing database and apply it. In this case, it would be:

    2-4      Column *q2*
    5-9      Column *q5*
    10-24    Column *q10*
    25 up    Column *q25*

What happens if quantity is one? It "falls back" to the price that is in the table products, column price.

After that, if there is a size attribute for the product, the column in the pricing database corresponding to that column is checked for additions or subtractions (or even percentage changes).

If you use this tag in the demo:

    [price code=99-102 quantity=10 size=XL]

the price will be according to the q10 column, adjusted by what is in the XL column. (The row is of course 99-102.) The following entry in pricing:

  code    q2   q5   q10  q25  XL
  99-102  10   9    8    7    .50

Would yield 8.50 for the price. Quantity of 10 in the q10 column, with 50 cents added for extra large (XL).

Following are several examples based on the above entry as well as this the entry in the products table:

  code    description   price    size
  99-102  T-Shirt       10.00    S=Small, M=Medium, L=Large*, XL=Extra Large

NOTE: The examples below assume a US locale with 2 decimal places, use of commas to separate, and a dollar sign ($) as the currency formatting.

  TAG                                          DISPLAYS
  ----------------------------------------     --------
  [price 99-102]                               $10.00
  [price code="99-102"]                        $10.00
  [price code="99-102" quantity=1]             $10.00
  [price code="99-102" noformat=1]             10
  [price code="99-102" quantity=5]             $9.00
  [price code="99-102" quantity=5 size=XL]     $9.50
  [price code="99-102" size=XL]                $10.50
  [price code="99-102" size=XL noformat=1]     10.5

Product discounts for specific products, all products, or the entire order can be configured with the [discount ...] tag. Discounts are applied on a per-user basis -- you can gate the discount based on membership in a club or other arbitrary means.

Adding [discount 99-102] $s * .9[/discount] deducts 10% from the price at checkout, but the price tag will not show that unless you add the discount=1 parameter.

    [price code="99-102"]            -->   $10.00
    [price code="99-102" discount=1] -->   $9.00

See Product Discounts. base code