> For the complete documentation index, see [llms.txt](https://galmis.gitbook.io/serializer-product-tracking/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://galmis.gitbook.io/serializer-product-tracking/getting-started/sharing-and-integration/development-api-reference/metafields.md).

# Metafields

[Individual sold items](/serializer-product-tracking/getting-started/item-management/manage-sold-items.md) and [product variant tracking preferences](/serializer-product-tracking/getting-started/setup-and-configuration/product-tracking-preferences.md) are stored in both the app's database and Shopify metafields. Shopify metafields let you access this data outside the app, e.g. automated [Shopify notifications](/serializer-product-tracking/getting-started/sharing-and-integration/share-item-information-with-customers/shopify-notifications.md).&#x20;

All metafields saved by the app are stored under the "**serializer**" namespace. Learn more about Shopify [metafields](https://help.shopify.com/en/manual/custom-data/metafields).

{% hint style="warning" %}
**Please only rely on the metafields documented on this page.**&#x20;

The app may populate other metafields for other purposes, e.g. settings. Please do not rely on such metafields, as the shape of the data may change.
{% endhint %}

## Product variant

Product variant metafields are stored in JSON format under the "**properties**" key. When populated, the following fields are available:

| Field name           | Type                                                                                                                                                                                                                                                                            | Description                                                                                                                                                                                                                                                                                                                                                                                                     |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **trackable**        | Boolean                                                                                                                                                                                                                                                                         | <p>When set to true, the app tracks individual items associated with the product variant. Currently, this flag also enables serial number tracking. The flag is reflected in the "Track individual items" checkbox in the app's product preferences.<br><br>Deleting the metafield is the same as setting the value to false.</p>                                                                               |
| **warrantyDuration** | <p>Undefined (not populated), null or JSON object containing the following fields:<br></p><ul><li><strong>unit</strong> - string. Possible values are "day", "month" or "year".</li><li><strong>value</strong> - integer, the minimum value is 1.</li></ul>                     | The default warranty duration is applied to individual items when they're sold.                                                                                                                                                                                                                                                                                                                                 |
| **customFields**     | <p>Undefined (not populated) or an array of JSON objects containing the following fields:<br></p><ul><li><strong>key</strong> - string. Max length - 30 characters. User entered key is displayed in the app's settings.</li><li><strong>trackable</strong> - Boolean</li></ul> | <p>It contains a list of <a href="/serializer-product-tracking/getting-started/setup-and-configuration/settings/track-custom-item-information.md">custom field</a> tracking preferences.</p><p></p><p>The trackable flags appear as "Track \<custom field name>" checkboxes in the app's product preferences.<br><br>Omitting a particular field's preferences is equivalent to setting trackable to false.</p> |

{% hint style="info" %}
Product variant [metafields can be set directly via Shopify admin API](https://shopify.dev/docs/api/admin-graphql/latest/mutations/metafieldsSet). The app automatically synchronises product variant metafields with its database.
{% endhint %}

### Example metafield values

#### Enable serial number tracking

```json
{ "trackable": true }
```

#### Enable serial number and warranty tracking with 2 year duration

```json
{ "trackable": true, "warrantyDuration": { "unit": "year", "value": 2 } }
```

#### Enable serial number and custom field tracking

```json
{ "trackable": true, "customFields": [{ "key": "my_dummy_field", "trackable": true }] }
```

## Order

{% hint style="warning" %}
Unlike Product variant metafields, order metafield edits **are not** synchronised with the app's database, yet. Therefore, please do not edit or delete order metafields. An API is planned for 2027. Please email me at <hello@galmis.com> if you're interested in the feature.
{% endhint %}

Order metafields are stored in JSON format under the "**properties**" key. When populated, the following fields are available:

| Field name                | Type           | Description                                                                                                                                                                                                                                                      |
| ------------------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **currentTotalTrackable** | Integer        | It highlights how many items within the order are currently trackable. Note that more items may be stored than currentTotalTrackable due to order edits outside the app. When this value is lower than the number of items stored, a warning appears in the app. |
| **items**                 | Array of items | See the table below for the information about item fields.                                                                                                                                                                                                       |

### Item fields

| Field name           | Type                                                                                                                                                                                                                                                                                                                                  | Description                                                                                                                                                                                        |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **lineItemId**       | Integer                                                                                                                                                                                                                                                                                                                               | Shopify's numeric line item ID.                                                                                                                                                                    |
| **productVariantId** | Integer                                                                                                                                                                                                                                                                                                                               | Shopify's numeric product variant ID.                                                                                                                                                              |
| **itemId**           | String                                                                                                                                                                                                                                                                                                                                | Globally unique item ID generated by the app. It can be used as a serial number.                                                                                                                   |
| **serialNumber**     | String or undefined (not populated)                                                                                                                                                                                                                                                                                                   | Manually entered serial number                                                                                                                                                                     |
| **warrantyDuration** | <p>Undefined (not populated), null or JSON object containing the following fields:<br></p><ul><li><strong>unit</strong> - string. Possible values are "day", "month" or "year".</li><li><strong>value</strong> - integer, the minimum value is 1.</li></ul>                                                                           | It contains a warranty duration for the item.                                                                                                                                                      |
| **customFields**     | <p>Undefined (not populated for the saved items before the "Custom fields" feature release) or an array of JSON objects containing the following fields:<br></p><ul><li>key - string. Max length - 30 characters. User entered key is displayed in the app's settings.</li><li>value - string. Max length - 200 characters.</li></ul> | It contains a list of all [custom field](/serializer-product-tracking/getting-started/setup-and-configuration/settings/track-custom-item-information.md) values and keys associated with the item. |
