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 | Custom Order Fields

A Custom Order Fields is typically used in conjunction with Custom Basket Fields. Basket Fields automatically get converted to Order Fields if they share the same field code. The Primary us is to collect additional data about an order. It's also used for admin Customer Relationship Management in Manage Orders.
ver. 9.0 and later

Video Transcript

Miva Merchant custom order fields are very similar to custom basket fields. However, instead of saving data with a basket, it saves data with an order. A custom order fields is typically used in conjunction with a custom basket field. The normal workflow is, you save some data with the shopper using a custom basket field and that data then gets converted to an order field once the order gets placed. Custom basket fields automatically get converted to custom order fields as long as they share the same field code. So this makes it important when you're defining your custom basket field codes, even though there are no strict limitations to it, if you want Miva to automatically convert it to a custom order field you must make sure that the field code you're defining for your custom basket field matches the field code you're defining for your custom order field. Miva will do all the heavy lifting. There's no special code you need to make this conversion happen. When an order is placed Miva will look at all the custom basket fields you have and will say, if any of these codes match the custom order fields you have set up within the Admin, you'll automatically transfer that data over and save it with the order. This is a great feature and really nice.

The primary use of a custom order field is to collect additional data about the order. Now, typically this is done by a custom basket field that transitions to a custom order field. However, it doesn't have to be. On the invoice page you can write any additional data to the order that you need. Since the order number is available, you simply pass in the values that you need and Miva will automatically save it with that order.

Another use for custom order fields has to do with the Admin. Under manage orders you can use custom order fields to create a lightweight CRM system where you or your Customer Service Reps can keep notes about the order. Things like emails that have been sent, phone calls, changes to the order. Any additional information you need can be saved in a custom order field where it's always available to view. Let's take a look at an example of how to take a custom basket field and convert it to a custom order field.

So back here in our text editor let's take a look at how to take a custom basket field and convert it into a custom order field. The first thing we need to do is collect some data somewhere in the site. Typically this is done during the checkout process. The OCST page is the page where a customer puts in their bill to and ship to information. So here, you can collect additional information about order notes, delivery date, where did you hear about us. Any information you need and you want to collect for the store. This will be done through an input. That can be a text input, a text area, a select dropdown; you the developer can determine any kind of input you want to use to collect the data. So here in this example, we're going to create a text input that's going to collect some order notes. Now the second part to this is that when this form gets submitted the next page it goes to is the OSEL page. This is where the customer selects their shipping and payment options. Now, if you remember from a previous video, where we were talking about Get and post parameters, any input on the page automatically becomes a global variable on the next page. So this order notes input that we have created here will become g.order notes on the next page. We can reference this value using g.order_notes variable. So on OSEL we want to read in that value, whatever the customer typed in and we want to save it to a custom basket field. So here I'm creating a custom basket field called order_notes. This will write the value of whatever was passed in through this text area and save it into this order notes custom basket field. And then just for fun, so we can validate that this actually works, I'm going to read back in this order notes field and save it into a new variable called My Order Notes and output that in my order notes in the page for the customer to see. This will show the customer what they typed in, but it will also validate for us that this is actually working correctly. So let's add both these code snippets to Miva and let's walk through the process. So the first one I'm going to put on OCST. So back here in my Miva Merchant Admin I'm going to look up OCST, and here I'm going to put it in the Customer Fields section. I'm just going to throw it at the bottom, but you can put it wherever you wanted to in terms of formatting and layout. So I'm going to save this. And I'm also going to take this code that we have for OSEL that saves this data to a custom basket field and reads it back in. Let's go to OSEL here. I'm just going to put this in the header and footer. It doesn't really matter where you put it on the page. Ok perfect, now that I have those two pieces, let's walk through the front end of the website. So I have a product in my cart and I'm going to go through the checkout process. So here's OCST. This is the first step of the checkout process. You'll see I have my "Enter Order Notes" field down here. So let me fill out all these fields first and then for my enter order notes I'm going to put "This is a test." Now I'll hit continue and go to the next page, which will be OSEL. So you'll see down here I have "Order Notes: This is a test." Perfect, exactly what we'd expect. So what this means is I was able to take that text that was in that text field that we created add that to the next page as a global variable and save that global variable into a custom basket field called order_notes.

Now the last step to this process is we need Miva to automatically convert that custom basket field into a custom order field. Miva will handle the part for you as long as the field codes match up. So, let's go back to the Miva Merchant Admin. I'm going to go to Utilities and then click on Custom Fields. I need to create that Custom Order Field so Miva has a place to save that data. So here for the type I'm going to make an order field. Again, this code is the most important part. This code must match the exact same code I used for the custom basket field, which we used order_notes and then Order Notes. I'm going to make this a text area so I can see it visually in the Admin. So here's my order notes custom order field. So let's jump back to the front end and complete the rest of the order. Ok, so here I am on the Invoice. The order was created. So let's go back to the Miva Merchant Admin and let's look up that order under Order Processing. So here's my order. Now, if we come here to this Custom Fields tab, you'll see there's no extra code we needed to add to invoice to convert the custom basket field to the custom order field. Miva does this for us automatically, which is really nice. Now here, this data was saved from customer input. However, you can also use custom order fields to act like a CRM tool. You can crate a custom order field for you or for your internal customer service reps to save data associated with an order. This is where you can keep track of order notes internal to you and things that have happened with that order.

Custom Order Fields are a very powerful tool that allows you to collect data from the shopper and save it with the order. These fields can also be used in batch reports, as well as the order emails. So they are very flexible and very powerful.



Example Code

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.