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

Scot Ranney • December 19, 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

mvkb_customfields