Get Orders Metadata
Summary of Changes: (The purpose of this table is to keep traceability and Product team to highlight the things that were changed into the scope, based on comments or discussions)
Version | Date | Created / Updated | Notes |
---|---|---|---|
v1.0 | 16.07.2024 | Bogomil | First publish |
We would like to introduce additional flow which will allow us do obtain the orders metadata (custom fields) from Shopify. The idea behind this meta fields is to allow the user to store custom information on the orders. In order to obtain that information we will need to call each order and obtain the metadata if any which we will be storing in the Shopify dependent order table.
The Get Orders Metadata is order per order and we want to try to get the metadata for all orders with status “Ready For Shipping”. Also in order not to get in a loop we want to introduce a new status field in Orders Shopify > Get Metadata which will be our second trigger.
Field Name | Field Type | Field Enumeration |
---|---|---|
Get Metadata | Dropdown | Pending (Default) |
Error Completed |
If we have Order > Status = “Ready For Shipping” and Orders Shopify > Get Metadata = “Pending” we want to get the metadata and once we obtain all the information even if there are no meta fields we want to set Orders Shopify > Get Metadata = “Completed”. If we receive any error during the get metadata we want to store it in Order Error table and set Orders Shopify > Get Metadata = “Error”.
API Documentation: https://shopify.dev/docs/api/admin-rest/2024-07/resources/metafield
API Call: /admin/api/2024-07/orders/{{Orders > Marketplace Order ID}}/metafields.json
Sample Request: GET [https://{{storename}}.myshopify.com/admin/api/2024-07/orders/6157711343953/metafields.json](https://bebemama-com.myshopify.com/admin/api/2024-07/orders/6157711343953/metafields.json)
Request Mapping: In the request URL we want to use the Orders > Marketplace Order ID.
Sample Response 200:
{
"metafields": [
{
"id": 39218749178193,
"namespace": "global",
"key": "label",
"value": "<p><a href=\"https://admin.shopify.com/store/bebemama-com/apps/256-metafields-editor/orders/6157711343953\">https://admin.shopify.com/store/bebemama-com/apps/256-metafields-editor/orders/6157711343953</a></p><p> </p>",
"description": "{\"mgType\":\"multi_line_text_field\",\"mode\":\"source\"}",
"owner_id": 6157711343953,
"created_at": "2024-07-16T10:26:34+03:00",
"updated_at": "2024-07-16T10:26:34+03:00",
"owner_resource": "order",
"type": "multi_line_text_field",
"admin_graphql_api_id": "gid://shopify/Metafield/39218749178193"
},
{
"id": 39218749210961,
"namespace": "global",
"key": "label2",
"value": "https://admin.shopify.com/store/bebemama-com/apps/256-metafields-editor/orders/6157711343953",
"description": "{\"mgType\":\"url\"}",
"owner_id": 6157711343953,
"created_at": "2024-07-16T10:26:34+03:00",
"updated_at": "2024-07-16T10:26:34+03:00",
"owner_resource": "order",
"type": "url",
"admin_graphql_api_id": "gid://shopify/Metafield/39218749210961"
}
]
}
Response Mapping:
Shopify Field | Hemi Field | Comment | |
---|---|---|---|
metafields | |||
id | N/A | ||
namespace | N/A | ||
key | Orders Shopify > Meta fields (Name) | We want to introduce a new field which will be as our Product Account > Item Specifics type and we need to have name and value. | |
value | Orders Shopify > Meta fields (Value) | We want to introduce a new field which will be as our Product Account > Item Specifics type and we need to have name and value. | |
description | N/A | ||
owner_id | N/A | ||
created_at | N/A | ||
updated_at | N/A | ||
owner_resource | N/A | ||
type | N/A | ||
admin_graphql_api_id | N/A |
Please note we can have more than one metafield for a specific order so we want to make sure we store all of them in Hemi.
Error Response 404: Full list of errors available here - https://shopify.dev/docs/api/usage/response-codes
{
"errors": "Not Found"
}
We want to store the "errors" in Order Error table and set Orders Shopify > Get Metadata = “Error”