Custom Field Reference Documentation
ver.9.0 and later
Custom Fields Use
Custom Fields is a module that comes installed by default in the core software. In PR8U9, the custom fields module received a huge overhaul which now included many new features, and a new layout.
One of the key new features was allowing store morph code to call functions directly inside the module through the use of < mvt:item/> tags. The two main components are reading a custom field and writing to a custom field.
Read Function Parameters
Read_***( id/code, custom_field_code, [destination] )
- Code/ID of the category/customer/order/product The parameter can either be a number, a string, or a variable. E.g. 1, '1', 'code', l.settings:product:code, g.Category_Code
- The custom fields to load. Expected values are ''(empty string), 'single_custom_field_code', 'comma_separated, list_of, custom_field, codes'
- A blank string loads all custom fields for that category/customer/order/product in an array. E.g. returns the custom fields 'size', 'height', 'weight', etc... (see examples below)
- A single custom field returns the custom field as the main member of the destination field (see examples below)
- A comma separated list of custom fields returns each custom field as a member of the destination field (see examples below)
- [Optional] The destination where the custom field values will be saved. Must be a variable
- Defaults to the item name. E.g. item name is customfields, so the structure is returned to l.settings:customfields (see examples below)
- Can pass in either a local or global variable of your choice. E.g. l.settings:my_custom_fields, g.My_Custom_Fields, etc...
Write Functions Parameters
Write_***( id/code, custom_field, value )
- Code/ID of the category/customer/order/product
- The parameter can either be a number, a string, or a variable. E.g. 1, '1', 'code', l.settings:product:code, g.Category_Code
- The custom field code to write to
- The parameter can either be a string or a variable. E.g. 'custom_field_code', g.Custom_Field_Code
- The value you want to set the custom field to
- The parameter can either be a string or a variable. E.g. 'custom field value', g.Custom_Field_Value
Note - Although it is completely viable to use hyphens when creating global variable names, it is not recommended if you will be using that global variable in a customfields tags. Take this snippet of code as an example:
The g.customer-comments is a valid global variable, however in that context, the custom fields function is going to try to evaluate it as an expression so it will interpret the dash as a subtraction sign:
g.customer - g.comments