![]() |
| > Home > Documentation > Latest documentation > Interchange ecommerce functions > Item attributes |
|
Item attributesInterchange allows attributes (such as size and colour etc.) to be set for each of the items in the cart. If multiple attributes are set, then they should be separated by a comma. Previous attribute values can be saved by means of a hidden field on a form, and multiple attributes for each item can be stacked on top of one another. The UseModifier local configuration directive is used to set the name of the modifier(s). For example, the following will attach both size and colour attributes to each item code that is added to the cart:
You can set the "mv_UseModifier" scratchpad variable as well as, or instead of, the UseModifier directive, using the following:
This has the same effect as the UseModifier directive, and allows multiple options to be set for products. Setting the mv_separate_items <form> variable, the mv_separate_items scratchpad value or the SeparateItems local configuration directive true forces each cart item onto its own line, simplifying attribute handling. The modifier value can be accessed in an [item-list] loop with the [modifier attribute] loop sub-tag, and form input fields can be generated using the [modifier-name attribute] loop sub-tag. This is similar to the way that quantity is handled, except that attributes can be "stacked" by setting multiple values on an order form. You cannot define a modifier named code, quantity and a few others, as they are reserved (see above). You must be sure that no fields in your forms have digits appended to their name if the variable name matches an attribute name you select. This is because the [modifier-name size] sub-tag will generate form variables with names such as size0, size1 and size2 etc. You can use a [loop arg="item item item"] list to reference multiple display or selection fields for modifiers, or you can use the [PREFIX-accessories] sub-tag that's available in most Interchange loop/list operations. The modifier value can then be used to select data from an arbitrary table for attribute selection and display. Below is a fragment from a shopping cart display form, which shows a selectable size with "sticky" setting. Note that this would always be contained within an [item-list][/item-list] container:
The above could just as easily be done with a radio button group combined with the [checked] tag. Interchange will automatically generate the above <select> box if either the [accessories code size] tag, or the [item-accessories size] loop sub-tag is used. See also
|
| Home | Legal nonsense | Privacy policy | Contact us |