Order extra fields allow you to save additional information into the order and get it via Ecwid REST API.
For example, if you need to save a cookie into an order or if you need to ask a customer a couple of questions at checkout – it's totally possible with the order extra fields. Later it can be retrieved via the Ecwid REST API when getting order details or searching for orders.
// Init order fields
window.ec = window.ec || {};
ec.order = ec.order || {};
ec.order.extraFields = ec.order.extraFields || {};
// Add new text field to order comments section at checkout
ec.order.extraFields.how_you_found_us = {
'title': 'How did you find us?',
'type': 'text',
'checkoutDisplaySection': 'payment_details'
};
Ecwid.refreshConfig && Ecwid.refreshConfig();
// Request
GET /api/v3/4870020/orders/104 HTTP/1.1
Host: app.ecwid.com
Content-Type: application/json;charset=utf-8
Authorization: Bearer e***s0
Cache-Control: no-cache
// Response
{
"total": 12.35,
"orderNumber": 104,
//...
"extraFields": {
"how_you_found_us": "I clicked an ad on Facebook."
}
}