Shopify Order Transform Scripts
The Shopify integration receives order data from Shopify and translates this into ShipStream Orders. This translation occurs just before the order is submitted and the Order Transform Script allows you to apply your own custom logic to the translation process using embedded Javascript code.
For example, one common use-case of such a script is to assign incoming orders to different ShipStream Brands based on the details of the Shopify order.
Script Authoring
Make sure you are familair with the Scripting Basics before proceeding.
The variables defined in the context of these scripts are:
order- the order information that will be submittedshopifyOrder- the order information from the Shopify source Fulfillment Order
Other methods available are:
print(string message)- add a message to the debug log
Example 'order' object
{"TODO":""}
Example 'shopifyOrder' object
{
"id": "4803026399999",
"app": {
"id": "gid://shopify/App/4999999",
"name": "Amazon by Codisto"
},
"billing_matches_shipping": true,
"created_at": "2023-06-30T16:12:03Z",
"currency": "USD",
"customer_locale": null,
"discount_codes": [],
"duties_incoterm": null,
"financial_status": "PAID",
"fulfill_at": null,
"fulfill_by": null,
"fulfillment_order_id": 25543659999,
"fulfillment_request": {
"message": "Latest user-provided message",
"notify_customer": true
},
"name": "#15551",
"note": "A note can go here",
"note_attributes": [
{
"key": "Amazon Order Id",
"value": "114-9999999-9999999"
},
{
"key": "Amazon Account",
"value": "ACME Inc."
}
],
"presentment_currency": "USD",
"processed_at": "2023-06-30T16:12:03Z",
"reference": "114-9999999-9999999",
"tags": [
"Amazon-US",
"FBM"
],
"test": false,
"total_discounts": "0.0",
"total_duties": null,
"total_price": "399.98",
"subtotal_price": "399.98",
"total_shipping": "0.0",
"total_weight": "9979",
"updated_at": "2023-06-30T23:17:02Z",
"shipping_address": {
"id": 210568299999,
"address1": "8020 N Coltrane Ln",
"address2": null,
"city": "Tucson",
"company": "",
"country": "United States",
"country_code": "US",
"email": "migueldonoso@gmail.com",
"first_name": "Miguel",
"last_name": "Donoso",
"phone": "5209999999",
"province": "Arizona",
"province_code": "AZ",
"zip": "85743"
},
"shipping_lines": [
{
"title": "Amazon Standard",
"code": "AMZSTD",
"source": "amazon",
"carrier_identifier": null,
"custom": false
}
],
"line_items": [
{
"id": 479097618467,
"fulfillment_order_id": 25543659999,
"quantity": 1,
"line_item_id": 12055235999998,
"inventory_item_id": 7238532562979,
"fulfillable_quantity": 1,
"variant_id": 7239969996835
},
{
"id": 479097651235,
"fulfillment_order_id": 25543659999,
"quantity": 1,
"line_item_id": 12055235999999,
"inventory_item_id": 5893532942371,
"fulfillable_quantity": 1,
"variant_id": 5912997330979
}
],
"order_line_items": [
{
"id": "12055235999998",
"sku": "T0003",
"quantity": 1,
"current_quantity": 1,
"custom_attributes": [
{
"key": "ASIN",
"value": "B075XX5JF4"
}
]
},
{
"id": "12055235999999",
"sku": "C0003",
"quantity": 1,
"current_quantity": 1,
"custom_attributes": [
{
"key": "ASIN",
"value": "B075XXV3BG"
}
]
}
]
}