NAV

Save hidden data to order

With order extra fields you can save any custom information into an order privately, optionally showing it in order details in storefront to customer or in the Ecwid Control Panel to merchant.

This is helpful when you need to save some technical stuff like campaign id, referring website address or something else. Check out more details on how it works below.

Saving hidden data to order

Save your extra field to an order placed by customer

<script>
// Initialize extra fields
ec.order = ec.order || {};
ec.order.extraFields = ec.order.extraFields || {};

// Save a single value for 'platform' field
ec.order.extraFields.platform = {
    'value': 'adobe_muse'
}

// Save another value for 'affiliate' field
ec.order.extraFields.affiliate = {
    'value': "Nick's warehouse"
}
</script>

Your hidden data will be saved into a config object used by Ecwid: ec.order and ec.order.extraFields. But in order to use it, you need to initialize it on a page. See the example code on the right.

Now that we’ve initialized the extra fields object, we can save some value into an order. Code on the right is an example of adding an extra field with the key platform and value adobe_muse.

If your code executed successfully, these fields will be saved when a customer places their order in an Ecwid store. See Get extra fields in REST API section to access them afterwards.