As of MiniVend 3.11, a flexible chained pricing scheme is available when the CommonAdjust directive is set.
NOTE: For compatibility with older carts, if both PriceAdjustment and CommonAdjust are set, and CommonAdjust contains a valid database identifier, the CommonAdjust value is used to set pricing adjustments based on item attributes. This is not discussed further in this section; all items below assume PriceAdjustment is not in use.
We talk below about a CommonAdjust string; it will be defined in due time.
A few rules about CommonAdjust, all assuming the PriceField directive is set to price:
If CommonAdjust
is set to any value, a valid CommonAdjust string or not, extended price adjustments are enabled. It may also hold the
default pricing scheme.
The price field may also hold a CommonAdjust string. It takes precedence over the default.
If the value of the CommonAdjust
directive is set to a CommonAdjust string, and the price field is empty or specifically 0, then it will be used to set the price of the items.
If PriceBreaks is in use, it's price will take precedence over the value of CommonAdjust
, though it may also contain a CommonAdjust string.
If no CommonAdjust strings are found, then the price will be 0, subject to any later application of discounts.
If another CommonAdjust string is found as the result of an operation, it will be re-parsed and the result applied. Chaining is retained; a fallback may be passed and will take effect.
Prices may be adjusted in several ways, and the individual actions are referred to below as atoms. Price atoms they may be final, chained, or fallback. A final price atom is always applied if it does not evaluate to zero. A chained price atom is subject to further adjustment. A fallback price atom is skipped if a previous chained price was not zero.
Atoms are separated by whitespace, and may be quoted (although there should not normally be whitespace in a setting). A chained item ends with a comma. A fallback item has a leading semi-colon. Final atoms have no comma appended or semi-colon prepended.
A settor is the means by which the price is set. There are There are eight different types of price settors. All settors can then yield another CommonAdjust string.
It is quite possible to create endless loops, so the maximum number of initial CommonAdjust strings is set to 16, and there may be only 20 iterations before the price will return zero on an error.
NOTE: Common needs are easily shown but not so easily explained; skip to the examples if the reference below if your vision starts to blur when reading the next section. 8-)
USAGE: Optional items below have asterisks appended. The asterisk should not be used in the actual string. Optional base or table always defaults to the active products database table. The optional key defaults to the item code except in a special case for the attribute-based lookup. The field name is not optional except in the case of an attribute lookup.
pricing:p1,p2,p3,p4,p5,p10:
is the same as
pricing:p1..p5,p10:
Leading non-digits are stripped, and the item quantity is compared with the numerical portion of the column name. The price is set to the value of the database column (numeric portion) that is at least equal to it but doesn't yet reach the next break.
WARNING: If the field at the appropriate quantity level is blank, a zero cost will be returned from the atom. It is important to have all columns populated.
&
sign is stripped and the code is passed to the equivalent of a [calc]
tag. No MiniVend tags can be used, but the &tag_data
routine is available, the current value of the price and quantity are
available as $s
, and the current item (code, quantity, price, and any attributes) are
available as $item
, all forced to the package Vend::Interpolate. That means that in a
UserTag:
$Vend::Interpolate::item is the current item $Vend::Interpolate::item->{code} gives key for current item $Vend::Interpolate::item->{size} gives size for current item (if there) $Vend::Interpolate::item->{mv_ib} gives database ordered from
[
) or underscore, it is parsed for MiniVend tags with variable substitution
(but no Locale substitution). You may define a price in a Variable in this fashion. The string is re-submitted as an atom, so it may yield yet
another settor.
mv_price
attribute of the shopping cart, and apply that price as the final price, if
it exists. The attribute must be a numerical value.
$
) the word
will be substituted; i.e. table:column:$
becomes table:column:word
.
settor
will be used as a key for the next lookup, as above.