Metafield Types
Metafield types let you specify which value you're going to store to simplify the validation and display. YouCan Metafields API currently support the following types:
Type | Description |
---|---|
number | Numeric value (price, rating, etc) |
string | Text representation (product description, etc) |
array | Array or JSON object |
boolean | true or false value |
date | A date in ISO 8601 format (YYYY-MM-DD). |
date_time | A date and time in ISO 8601 format (YYYY-MM-DDTHH:MM:SS). |
money | A numeric amount, with a currency code that matches the store's currency. {"amount": "5.99", "currency_code": "CAD"} |
url | A URL with one of the allowed schemes: https, http, mailto, sms, tel. |
volume | A value and a unit of volume. Valid unit values: ml, cl, l, m3 (cubic meters), us_fl_oz, us_pt, us_qt, us_gal, imp_fl_oz, imp_pt, imp_qt, imp_gal. { "value": 20.0, "unit": "ml"} |
weight | A value and a unit of weight. Valid unit values: oz, lb, g, kg. {"value": 2.5,"unit": "kg"} |
Each of the types mentioned above supports a list type (list.{type}
), as an example list.number
can store a list of numbers ([3, 4, 2, 12, 123]
).
Note: All values are stored as strings internally and cast using the selected type on display.