Miva Merchant Development by Scot's Scripts

CUSTOM FIELDS: Basket / Order

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: Basket / Order

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 19, 2023 (updated: December 20, 2023)


Custom basket fields are used to store info throughout the customer session.

Custom order fields can have custom basket field data automatically inserted on order fulfillment and then viewed in the admin in the order. Click on the custom fields link above the order data (miva admin.)

The requirement is the custom basket field code must match an existing custom order field code.

Important:

Use letters and underscores in your custom field codes otherwise the page items below will not work.

Write to a custom basket field using page items:

<mvt:item name="customfields" param="Write_Basket( 'customer_ip', s.remote_addr )" />
<mvt:item name="customfields" param="Write_Basket( 'my_basket_field', 'hello world' )" />

Make a custom order field with the code customer_ip to store the data put in the customer_ip custom basket field above. Data can be viewed in the admin order view area.

Read custom basket field:

<mvt:item name="customfields" param="Read_Basket( 'customer_ip', l.settings:cf:customer_ip )" />
<mvt:item name="customfields" param="Read_Basket( 'my_basket_field', l.settings:cf:my_basket_field )" />

Best Practice: It's a good idea to use the structure cf: or some other designation to keep all custom field data in one bucket. This is good practice for all use of custom variables in templates and modules.

Read all custom basket fields:

<mvt:comment>
#
# read_basket loads all custom basket field data into l.settings:customfields
#
</mvt:comment>

<mvt:item name="customfields" param="Read_Basket( '' )" />

<mvt:foreach iterator="basket" array="customfields">
	<div>
		&mvte:basket:code; - &mvte:basket:value;
	</div>
</mvt:foreach>

https://www.scotsscripts.com/mvblog/custom-fields-basket-order.html

customfields