24/7 Support: 800.608.6482

Videos

Try our new AI assistant by clicking the chat icon in the lower right corner.

Developer Videos

Videos | New Custom Fields

You can now use Custom Fields on any page thanks to built in Template Level Functions to read/write custom fields. You no longer need to first assign a custom field to a page in order to use it. There are also now new custom fields for Custom Basket and Order Fields.

ver. 9.0 and later

Video Transcript

To solve all the problems of the existing custom fields functionality, in 2013 Miva released an update to the custom fields module to greatly extend its functionality. The most critical piece to this was the ability to use custom fields on any page, both read and write. In order to do this Miva introduced new template level functions. These functions are extremely powerful and give you, the Developer, the ability to read any custom field or all custom fields and write any custom fields on any page within the software.

A second problem it solved is you no longer need to first assign a custom field to a page in order to use it. Custom fields just work. You can use them on the Storefront page, the checkout page, the category page, the product page, it doesn’t matter what page you’re on, the custom fields will automatically work. I’ll show you how we do this in a second. If you create a new page you will have to assign one of two items to get it to work. For all of the built in existing pages, custom fields works right out of the box.

With the update to the custom fields functionality, we’ve also introduced two new types of custom fields. A custom basket field and a custom order field. Now both of these didn’t exist previously and are great additions to the custom fields functionality. We’re going to dive into both of these in one of the next videos.

Custom basket fields are associated with a shopper or with a basket. You could think of them as a cookie, but instead of being saved at the browser level, they are actually saved in the database.

The custom order fields are fields that are associated with an order. So once an order is placed, you can save custom data along with that order. Custom order fields are a great tool to create lightweight CRM so you can save order notes along with each order. It’s important to note that all these functions that were released work alongside the legacy way to call in custom fields to a page template. So as a developer it’s important to understand both ways because you’ll see both used in a template. Now as time goes on the legacy custom fields will most likely fade out, but to maintain backwards compatibility both still work and will work alongside each other. So on a product page you can use one of the new product read functions to call in a custom product field and you can also use the legacy way to do it, which we saw in the last video. However, I can tell you, that once you get familiar with the new custom fields functions and start using them, you’ll never go back to using the old way ever again. The new functions are so powerful and flexible as well as easy to remember and use, that they make working with custom fields as a developer, really a pleasure.

Before we dive into the new template level functions, I want to jump over to Miva and show you how the custom fields are able to work on every page without first needing to assign any item to the page. So here, back at the Miva Admin, I’m going to jump to the Storefront page. I’m going to go over to the Items tab to see all of the assigned items to this page. When you turn on the new custom fields, it actually registers itself as an extension to the store item. The reason it does this is because the store item is used on every single frontend page. Now, if you remember from previous videos, the store item contains information about the store, details such as the store name, store code, the owner information, etc. All that is stored in a store structure. Well, because that store item is by default assigned to every frontend page, it made sense to make the custom fields module to extend the store item. This way there is not a separate item that needs to be assigned to a page.

If I edit this store item here and go to extensions, you’ll see that the custom fields module is an extension of the store item. This is what enables the custom fields function to work on any page on the Miva Merchant Admin. Say for example you created a new page, I’ll go to “Menu,” “User Interface,” and then I’ll click the “+” button to create a new page. I’m just going to call it “Test” and I’m going to leave it a blank template. So if I add this page, I now have a new page template I can use within Miva. Say for example I wanted to call in a custom field or use one of the custom field functions on this page. In order to do so, I first need to assign the store, the store item, which will make available all the new custom field functions and if we actually edit this. You’ll see it also has the Extension of Custom Fields. Or, I could also assign the custom fields item itself. Both will work but you only really need to assign one or the other. You can do both, it won’t hurt anything, but it’s not required.

Now that we know how the new custom field functions are able to work across any page in the Miva Admin, let’s dive in and look at the functions themselves.



Reference Documentation




Looking for Developer Docs?

We have a whole section for that, including: Developer Training Series, Template Language docs, Module Development tutorials and much, much more.

Head to the Developer Section

Copyright © 1997 – 2024 Miva®, Miva Merchant®, MivaPay®, MivaCon®, Camp Miva®, Miva Connect®, Miva, Inc. All Rights Reserved.