LogoLogo
  • 🏃‍♀️ Get started
    • Create your first integration
      • Step 1 - Creating your Source & Destination System keys
        • Shopify Key
        • FTP Key
      • Step 2 - Select a Source Function
      • Step 3 - Select a Destination Function
      • Step 4 - Select a Transformation
      • Step 5 - Put it all together to create a Stream
      • Step 6 - Run your stream
    • Go-live best practice
  • 🏄🏻‍♀️ Integration Tutorials
    • Shopify with Descartes Peoplevox
    • Shopify with FTP
      • Shopify with FTP
      • Shopify with FTP (Part 2)
    • Shopify with ReBOUND
    • WooCommerce
      • WooCommerce with FTP
    • NetSuite
  • 🏗️ Creating streams
    • Intro
    • Streams
      • Web hook installation
      • Web hook support
        • DEAR Systems
        • Descartes Peoplevox
        • Shopify
    • Systems
      • System library
        • DEAR Systems
        • Email
        • FTP
        • Descartes Peoplevox
        • Magento 1.x
        • Magento 2.x
        • ParcelLab
        • ReBOUND
        • Shopify
        • WooCommerce
    • Keys
      • Key library
        • Shopify private apps
        • Netsuite
        • FTP and sFTP
        • oAuth
    • Sources
    • Transformations
      • Public Transformations
      • Private Transformations
      • Customising a Public Transformation
      • Write a custom transformation
        • Transformation Library
        • Example 1 - Sales Order
        • Example 2 - Shipment
    • Destinations
      • Aggregated Events
    • Data uploads
    • Lookup table
  • 🔧 Editing streams
    • Updating source and destinations
    • Deleting a stream
  • 🎛️ Monitoring streams
    • Job Statuses
    • Event Statuses
    • Resending data
      • Replicate Job
      • Replicate Event
      • Replicate Event without Event in Control Panel
    • Reporting
      • Jobs
      • Events
      • Entities
    • Alerts
  • ⚙️ Administration
    • Login and security
      • Two factor authentication (2FA) setup
        • Signup to HighCohesion without QR scan
    • Creating an organisation
    • Billing Information
    • Creating a user
    • Roles & Permissions
  • 💁🏽 Help and support
    • Glossary of platform terminology
    • Security standards
    • Data retention policy
    • Contact us
Powered by GitBook
On this page
  • Scenario
  • Starting with the destination schema
  • Reviewing the input data
  • Creating the transformation
  • Example with line items

Was this helpful?

  1. 🏗️ Creating streams
  2. Transformations
  3. Write a custom transformation

Example 2 - Shipment

Building an example order shipment transformation file from scratch.

PreviousExample 1 - Sales OrderNextDestinations

Last updated 3 years ago

Was this helpful?

Scenario

In our first example we created a sales order transformation file that could be used in the example of taking sales order data from a ecommerce system and sending it to a 3PL provider as a CSV file. Building on this, in this second example we're going to have a look at building a custom Shipment transformation file. This scenario would be for shipment data flowing back to the ecommerce system from the 3PL provider.

In this example we're going to move data from a CSV file on FTP to the Shopify fulfilment REST API.

Starting with the destination schema

To begin with lets take a look at the fields that Shopify needs to create a fulfilment against a Sales Order, the example below being taken from

{
  "fulfillment": {
    "location_id": 905684977,
    "tracking_number": "123456789010",
    "tracking_company": "fed ex",
    "tracking_url": "https://www.new-fedex-tracking.com/?number=123456789010",
    "line_items": [
      {
        "id": 466157049
      },
      {
        "id": 518995019
      },
      {
        "id": 703073504
      }
    ]
  }
}

Reviewing the input data

Next lets take a look at the example CSV file that has been provided from the 3PL partner:

"order","shipment_date","courier","tracking_code","tracking_url"
"#GB123042","2021-07-01","DPD","DPD1234567890-AA","https://www.dpd.co.uk/apps/tracking/?reference=DPD1234567890-AA"
"#GB123043","2021-07-01","DPD","DPD1234567891-BB","https://www.dpd.co.uk/apps/tracking/?reference=DPD1234567891-BB"
"#GB123044","2021-07-01","DPD","DPD1234567892-CC","https://www.dpd.co.uk/apps/tracking/?reference=DPD1234567892-CC"

In this typical CSV file that has been provided by a 3PL partner, we can see the basic fields required to keep the ecommerce system up to date with the shipment information.

Creating the transformation

Above, we have taken a look at the required destination format (payload out) and the input data from the 3PL (payload in). The next step is to bring this all together in our transformation file, mapping the input data to create the output data.

The example tabs below show the data as received by HighCohesion, the transformation and finally the payload out that would be sent to Shopify.

{
    "order": "#GB123042",
    "shipment_date": "2021-07-01",
    "courier": "DPD",
    "tracking_code": "DPD1234567890-EE",
    "tracking_url": "https://www.dpd.co.uk/apps/tracking/?reference=DPD1234567890-EE"
}
{
  "fulfillment": {
    "location_id": {
      "*static_value*": 12345678900
    },
    "tracking_number": {
      "*ppk*": "tracking_code"
    },
    "tracking_company": {
      "*ppk*": "courier"
    },
    "tracking_url": {
      "*ppk*": "tracking_url"
    }
  }
}
{
  "fulfillment": {
    "location_id": 12345678900,
    "tracking_number": "DPD1234567890-EE",
    "tracking_company": "DPD",
    "tracking_url": "https://www.dpd.co.uk/apps/tracking/?reference=DPD1234567890-EE"
  }
}

The transformation file ends up being quite simple, just four fields are required to ship the sales order in Shopify. Three of these fields are mapped using the *ppk* option, meaning that the transformation logic will use a value from the payload in. The fourth value location_id is populated using a *static_value* which in the example above enters the value 12345678900 in to the payload out.

No Products?

In the example above there are no line items covered in the transformation file. This is due (in this example) to the 3PL file not containing the line level detail. In the HighCohesion system, if there are no line items, then all lines will be fulfilled automatically.

Example with line items

Building on the example above, some 3PL partners offer good line level detail which can be mapped over to Shopify to create partial or split shipments. In the example below we look at how the source information has changed and how the transformation file is changed to handle it:

"order","sku","qty","shipment_date","courier","tracking_code","tracking_url"
"#GB123042","ABC001",3,"2021-07-01","DPD","DPD1234567890-AA","https://www.dpd.co.uk/apps/tracking/?reference=DPD1234567890-AA"
"#GB123042","CEG032",4"2021-07-01","DPD","DPD1234567890-AA","https://www.dpd.co.uk/apps/tracking/?reference=DPD1234567890-AA"
"#GB123042","AGJF22",1"2021-07-01","DPD","DPD1234567890-AA","https://www.dpd.co.uk/apps/tracking/?reference=DPD1234567890-AA"
"#GB123043","BBC901",1"2021-07-01","DPD","DPD1234567891-BB","https://www.dpd.co.uk/apps/tracking/?reference=DPD1234567891-BB"
"#GB123043","BBC902",1"2021-07-01","DPD","DPD1234567891-BB","https://www.dpd.co.uk/apps/tracking/?reference=DPD1234567891-BB"

The lines of the CSV will be grouped together by the common piece of data, in this case the order column that contains the order number will be used to group the data.

{
    "order": "#GB123042",
    "sku": "ABC001",
    "qty": 3,
    "shipment_date": "2021-07-01",
    "courier": "DPD",
    "tracking_code": "DPD1234567890-EE",
    "tracking_url": "https://www.dpd.co.uk/apps/tracking/?reference=DPD1234567890-EE"
    "line_items": [
        {
            "order": "#GB123042",
            "sku": "ABC001",
            "qty": 3,
            "shipment_date": "2021-07-01",
            "courier": "DPD",
            "tracking_code": "DPD1234567890-EE",
            "tracking_url": "https://www.dpd.co.uk/apps/tracking/?reference=DPD1234567890-EE"
        },
        {
            "order": "#GB123042",
            "sku": "CEG032",
            "qty": 4,
            "shipment_date": "2021-07-01",
            "courier": "DPD",
            "tracking_code": "DPD1234567890-EE",
            "tracking_url": "https://www.dpd.co.uk/apps/tracking/?reference=DPD1234567890-EE"
        },
        {
            "order": "#GB123042",
            "sku": "AGJF22",
            "qty": 1,
            "shipment_date": "2021-07-01",
            "courier": "DPD",
            "tracking_code": "DPD1234567890-EE",
            "tracking_url": "https://www.dpd.co.uk/apps/tracking/?reference=DPD1234567890-EE"
        }
    ]
}
{
    "fulfillment": {
        "location_id": {
            "*static_value*": 12345678900
        },
        "tracking_number": {
            "*ppk*": "tracking_code"
        },
        "tracking_company": {
            "*ppk*": "courier"
        },
        "tracking_url": {
            "*ppk*": "tracking_url"
        },
        "line_items": {
            "*list*": "line_items",
            "*list_fields*":
            {
                "sku": {
                    "*ppk*": "sku"
                },
                "quantity": {
                    "*ppk*": "qty"
                }
            }
        }
    }
}
{
  "fulfillment": {
    "location_id": 12345678900,
    "tracking_number": "DPD1234567890-EE",
    "tracking_company": "DPD",
    "tracking_url": "https://www.dpd.co.uk/apps/tracking/?reference=DPD1234567890-EE"
    "line_items": [
      {
        "sku": "ABC001",
        "quantity": 3
      },
      {
        "sku": "CEG032",
        "quantity": 4
      },
      {
        "sku": "AGJF22",
        "quantity": 1
      },
    ]
  }
}

The transformation above adds in a *list* and *list_fields* block in order to create the array of line items that is sent to Shopify.

SKU vs ID In the example above we use the SKU code in the line items as that is the data that is available from the 3PL partner shipment file. The HighCohesion system will automatically match SKU code to the line item ID in Shopify for fulfilment to work correctly.

For a tutorial example for , check .

https://shopify.dev/api/admin/rest/reference/shipping-and-fulfillment/fulfillment#create-2021-04
FTP to Shopify integration with CSV files
this link