Knowledgebase:
Release 8 update 9 Custom fields
Posted by Wayne Smith, Last modified by Wayne Smith on 07 April 2014 07:50 AM

Custom Fields Use
One of the key new features was allowing store morph code to call functions directly inside the module through the use <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] )
Parameters

  • 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 )

Parameters

 

  • 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




Read Functions
 

Code:
<mvt:item name="customfields" param="Read_Category_Code( 'category_code', 'custom_field_code', l.settings:customfields )" />
<mvt:item name="customfields" param="Read_Category_ID( 1, 'custom_field_code', l.settings:customfields )" />
<mvt:item name="customfields" param="Read_Customer_Login( 'test@test.com', 'custom_field_code', l.settings:customfields )" />
<mvt:item name="customfields" param="Read_Customer_ID( 666, 'custom_field_code', l.settings:customfields )" />
<mvt:item name="customfields" param="Read_Order( 1000, 'custom_field_code', l.settings:customfields )" />
<mvt:item name="customfields" param="Read_Product_Code( 'product_code', 'custom_field_code', l.settings:customfields )" />
<mvt:item name="customfields" param="Read_Product_ID( 1, 'custom_field_code', l.settings:customfields )" />

Write Functions

Code:
<mvt:item name="customfields" param="Write_Category_Code( 'category_code', 'custom_field_code', 'value' )" />
<mvt:item name="customfields" param="Write_Category_ID( 1, 'custom_field_code', 'value' )" />
<mvt:item name="customfields" param="Write_Customer_Login( 'test@test.com', 'custom_field_code', 'value' )" />
<mvt:item name="customfields" param="Write_Customer_ID( 666, 'custom_field_code', 'value' )" />
<mvt:item name="customfields" param="Write_Order( 1000, 'custom_field_code', 'value' )" />
<mvt:item name="customfields" param="Write_Product_Code( 'product_code', 'custom_field_code', 'value' )" />
<mvt:item name="customfields" param="Write_Product_ID( 1, 'custom_field_code', 'value' )" />

Miscellaneous Functions

Code:
<mvt:item name="customfields" param="Read_Basket( 'custom_field_code', l.settings:customfields )" /> /*Reads a custom field from the sNN_BasketInfo table*/
<mvt:item name="customfields" param="Write_Basket( 'custom_field_code', 'value' )" /> /*Writes a custom field to the sNN_BasksetInfo table*/
<mvt:item name="customfields" param="Debug()" /> /*Outputs any errors that may have occurred, such as a non-existent product code*/

Examples

Code:
<mvt:item name="customfields" param="Read_Product_ID( 62, '', l.settings:test )" />
<mvt:foreach iterator="field" array="test">
    &mvte:field:code;<br/>
    &mvte:field:name;<br/>
    &mvte:field:value;<br/>
</mvt:foreach>
Code:
<mvt:item name="customfields" param="Read_Order( 1000, '' )" />
<mvt:foreach iterator="field" array="customfields">
    &mvte:field:code;<br/>
    &mvte:field:name;<br/>
    &mvte:field:value;<br/>
</mvt:foreach>
Code:
<mvt:item name="customfields" param="Write_Basket( 'lamp_color', 'green' )" />
<mvt:item name="customfields" param="Read_Basket( 'lamp_color', l.settings:custom_basket_lamp_color )" />
&mvte:custom_basket_lamp_color;
Code:
<mvt:item name="customfields" param="Read_Customer_Login( 'test@mivamerchant.com', 'middle_name, maiden_name' )" />
&mvte:customfields:middle_name;
&mvte:customfields:maiden_name;
Code:
<mvt:item name="customfields" param="Read_Category_Code( 'teams', 'dodgers, angels', g.Custom_Fields )" />
&mvte:global:Custom_Fields:dodgers;
&mvte:global:Custom_Fields:angels;
Code:
<mvt:item name="customfields" param="Write_Basket( 'my_made_up_code', 'This is my value I am going to write to the basket' )" />
<mvt:item name="customfields" param="Write_Basket( 'color', 'red' )" />
<mvt:item name="customfields" param="Read_Basket( '' )" />
<mvt:foreach iterator="basket" array="customfields">
     &mvte:basket:code; - &mvte:basket:value;<br/>
</mvt:foreach>
 
Additional Resources
 
(1 vote(s))
This article was helpful
This article was not helpful

Help Desk Software by Kayako support.miva.com/supportsuite/index.php?