Miva Merchant Modules and Development
Want to start an online store? We work with you from start to finish, from commerce platform to design to SEO.
Experience counts, and we have a lot.

CUSTOM FIELDS: MivaScript Manipulation

Scot Ranney • December 22, 2023


Customer Custom Fields

<MvASSIGN NAME = "l.ok" VALUE = "{ [ g.Module_Root $ '/modules/util/customfld.mvc' ].CustomerFieldValue_Load_CodeAndCustomer('custom_field_code', l.settings:customer:id, l.settings:field, l.settings:value) }" />
<MvCOMMENT>
#
# sNN_CFM_CustFields
#
</MvCOMMENT>

<MvASSIGN NAME = "l.field"		VALUE = "">

<MvASSIGN NAME = "l.field:id"		VALUE = "{ CustomerFieldValues.d.id }">
<MvASSIGN NAME = "l.field:group_id"	VALUE = "{ CustomerFieldValues.d.group_id }">
<MvASSIGN NAME = "l.field:code"		VALUE = "{ CustomerFieldValues.d.code }">
<MvASSIGN NAME = "l.field:name"		VALUE = "{ CustomerFieldValues.d.name }">
<MvASSIGN NAME = "l.field:fieldtype"	VALUE = "{ CustomerFieldValues.d.fieldtype }">
<MvASSIGN NAME = "l.field:info"		VALUE = "{ CustomerFieldValues.d.info }">

<MvASSIGN NAME = "l.ok" VALUE = "{ [ g.Module_Root $ '/modules/util/customfld.mvc' ].CustomerField_Update(l.field) }" />

<MvCOMMENT>
#
# sNN_CFM_CustValues
#
</MvCOMMENT>

<MvASSIGN NAME = "l.value"				VALUE = "">

<MvASSIGN NAME = "l.value:field_id"	VALUE = "{ CustomerFieldValues.d.field_id }">
<MvASSIGN NAME = "l.value:product_id"	VALUE = "{ CustomerFieldValues.d.product_id }">
<MvASSIGN NAME = "l.value:value"	VALUE = "{ CustomerFieldValues.d.value }">
<MvASSIGN NAME = "l.value:value_long"	VALUE = "{ CustomerFieldValues.d.value_long }">

<MvASSIGN NAME = "l.ok" VALUE = "{ [ g.Module_Root $ '/modules/util/customfld.mvc' ].CustomerFieldValue_Set(l.field_id,l.customer_id,'some value') }" />

Product Fields

<MvASSIGN NAME = "l.ok" VALUE = "{ [ g.Module_Root $ '/modules/util/customfld.mvc' ].ProductFieldList_Load_All(l.customfields) }" />
<b>custom fields</b>
<br>
<MvFOREACH ITERATOR = "l.field" INDEX = "l.pos" ARRAY = "l.customfields">
	<MvEVAL EXPR = "{ debugarray(l.field) }">
	<br>
</MvFOREACH>

Load ALL Custom Field Values At Once

Works for all types of custom fields, including page custom fields (seo tab).

l.null_code is where the custom field code should be, but if it's null the function will load all the fields and values and put them in their own structures.

<MvASSIGN NAME = "l.ok" 
		  VALUE = "{ [ g.Module_Root $ '/modules/util/customfld.mvc' ].Read_Category_Code(l.module, '', l.category:code, l.null_code, l.custom_field_stuff) }" />

https://www.scotsscripts.com/mvblog/custom-fields-mivascript-manipulation.html

mvkb_customfields mvkb_mivascript