Gift messages are not enabled by default in Magento 2 and you will need to either install an additional module or extension or utilise a third-party app to enable gift message support for your store. As a result, gift message data will be stored in different places in order or shipment data from store to store depending on how support has been implemented.


In order to successfully download gift messages from your Magento store, once you have enabled Downloading Gift Messages from your Magento 2 settings page, you will need to enter a path to direct Shiptheory to where it can find gift message data in your orders:



Gift Message Path syntax

The gift message path uses dot notation to dictate how to navigate through the JSON data Shiptheory downloads from Magento when processing your orders and shipments.


For example:

order.extension_attributes.gift_message.message


Would extract "This is a gift message ..." from the order data below:

{
"order": {
"extension_attributes": {
"gift_message": {
"customer_id": 0,
"gift_message_id": 823,
"message": "This is a gift message ...",
"recipient": null,
"sender": null
}
}
}
}



  • Depending on where your gift messages are stored, the path can guide Shiptheory to download the message from either your Shopify order or shipment data. As such, the path should always start with the word "orderor "shipment".

  • The path is Case Sensitive. For example, "name" will match "name" but not "Name" or "NAME".


  • {n} can be used to match any unordered elements, such as multiple line items or notes.

  • If multiple matches can be made, only the first match is returned.

  • If you need to match an element where an attribute matches a certain value, you can add a match condition to the path in square brackets. For example, if you had an unordered list of products and you wanted to return the name of a productwith a certain SKU, you could use something like the example below:

    order.items.{n}[sku=AB123].name



Data Path testing tool

We have a tool to help you build and test your data path, available here: https://helm.shiptheory.com/sandbox/find_data_path.


Simply copy-and-paste the JSON data from a Magento 2 order or shipment into the tool and you will be able to enter and test your data path before saving to your Magento 2 settings.



More examples

{
"order": {
"entity_id": 2048,
"extension_attributes": {
"notes": [
{
"name": "note",
"value": "Note A"
},
{
"name": "note",
"value": "Note B"
}
]
},
"increment_id": "000140283",
"items": [
{
"item_id": 5756501196957,
"name": "White T-Shirt",
"notes": [
{
"name": "gift_message",
"value": "Happy Birthday Jack!"
}
],
"price": 13.95,
"product_type": "simple",
"qty_ordered": 1,
"sku": "tshirt-w"
},
{
"item_id": 5756501196235,
"name": "Blue T-Shirt",
"notes": [
{
"name": "gift_message",
"value": "Merry Christmas Sophie!"
}
],
"price": 13.95,
"product_type": "simple",
"qty_ordered": 1,
"sku": "tshirt-b"
}
],
"note": "This is an order note"
}
}


  • order.note
    Returns: This is an order note

  • order.extension_attributes.notes.{n}.value
    Since this has multiple matches (Note A and Note B), the first match is returned
    Returns: Note A

  • order.items.{n}[sku=tshirt-b].name
    Returns: Blue T-Shirt



If you have any questions regarding this or anything else, please don't hesitate to get in touch with the Shiptheory support team!