Miva Merchant Development by Scot's Scripts

CUSTOM FIELDS: MivaScript Manipulation

Miva Random Code Trivia

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.

WARNING:

This information is offered "AS IS" for internal reference only. Use at your own risk.
Does AI actually understand your Miva Merchant store? Our smart JSON-LD schema generator makes sure it does. Contact us to get started. (more info)
SEO Audit & Inquiries • News & Updates • SEO for Miva Merchant

CUSTOM FIELDS: MivaScript Manipulation

THIS CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED;
THE AUTHOR DISCLAIMS ALL LIABILITY FOR ANY DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR STORE DISRUPTIONS ARISING FROM ITS USE.

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

customfields mivascript