Search…
Shopify with FTP (Part 2)
Taking the shipment data back from FTP to Shopify.
In our first Shopify to FTP tutorial (part one) we looked at moving data from Shopify out to an FTP server as a CSV file. In this second part we will look at moving data back from the FTP location to update Shopify. To follow on from part one, in this part we will move shipment data back from the FTP to complete the sales order loop, ensuring that orders in Shopify are kept up-to-date with what the 3PL has shipped.

Prerequisites

This tutorial should be followed to create a data stream back from the FTP location to Shopify. These steps assume that you have the following accounts and information to hand:
  • Completion of Part 1 - Please complete part one of this tutorial here.

Guide

All of the following steps should be taken in order. Unless specified the steps assume that you are logged in to the HighCohesion control panel.

1. Keys

In part one of this tutorial two keys were created, these should be in your HighCohesion account as:
  • FTP Key
  • Shopify Key
No additional keys are required for this second part.

2. Source

A source is where the data will be coming from. To create a source log in to Control Panel and select sources from the right side panel and select Create Source. To create a source you will need the following information below.
  • Title - Enter a title for the source, e.g. Get FTP Shipments
  • System - Select FTP from the systems list.
  • Function - Select function from dropdown in this case GetFiles::fromFtp()
  • Key - Select the FTP key that was created in step 1 above.
  • Trigger - Choose an option from the drop down list, either Manual, Scheduled or Web hook. For the purpose of the tutorial we are going to select "Manual", however after the smoke test in step 6 you may want to change this to scheduled.
  • Settings - Add the following setting so that the source will only collect files that start with the prefix SHP_ and are located in the folder /outbound/shipments on the FTP. The setting archive will also move the file to an archive folder on the FTP once collected.
    1
    file_prefix = "SHP_"
    2
    file_type = "csv"
    3
    remote_path = "/outbound/shipments"
    4
    move_remote_file = "archive"
    Copied!
For the scenario in this tutorial we are going to get a shipments CSV file from our dummy 3PL FTP. However this same process could be used for any other information coming from FTP, such as Products, Customers, Discounts etc, these would just require a different Function / Setting on the destination side.
Trigger options for source includes web hooks, manual and scheduled. If you choose scheduled you will need to set a scheduled time in the trigger option field. For scheduling options checkout this site https://crontab.guru/

3. Destination

The destination is where the data will be streamed to after it has been transformed. To create a destination log in to Control Panel and select Destinations from the right side panel and select Create Destination. To create a Destination you will need the following information:
  • Title - Enter a title for the destination, e.g Shopify Post Shipments
  • System - Select Shopify from the systems list.
  • Function - Select function from dropdown in this example PostShipments::toShopify()
  • Key - Select the Shopify key that was created in step 1 above.
  • Trigger - From the dropdown list select "Real Time".
  • Settings - Leave empty, no additional settings are required.

4. Transformation

The transformation file is required to translate data between the source system format and destination system format. To create a transformation file log in to Control Panel and select Transformations from the right side panel and select Create Private Transformation. The transformation creation screen gives the following inputs:
  • Title - A meaningful title e.g "Shopify x FTP CSV :: Sales Order Data"
  • Source - Choose the source system from the dropdown list, Shopify in this case.
  • Destination - Choose the destination system from the dropdown list, FTP in this case.
  • Primary Data Type - The data type will be what data is being streamed e.g order, product, payment etc... in this example the data type will be order.
  • Content - This will contain the mapping file which translate between the source and destination, for details on how to create a transformation file please check this link. For this example, please paste in the transformation below:
example_shipments_transformation.json
1
{
2
"fulfillment": {
3
"order_number": {
4
"*ppk_tracked*": {
5
"*ppk*": "OrderNumber",
6
"*tracked_field*": [
7
"s_id",
8
"name"
9
]
10
}
11
},
12
"location_id": {
13
"*stream_setting*": "location_id"
14
},
15
"tracking_number": {
16
"*ppk*": "CourierTrackingCode"
17
},
18
"notify_customer": {
19
"*static_value*": true
20
}
21
}
22
}
Copied!
The transformation file logic above is the simplest form of shipment data to be sent to shopify and has been built to work with the example smoke test CSV file shown below in part 6a. This transformation maps the order number and tracking number from the smoke test CSV file in to the Shopify fulfilment format.
Information on how to create transformation files can be found in this Example Tutorial, additionally all transformation functions are details on the Writing a Transformation page.

5. Stream

Step five in the process is to configure the our data stream. The stream in HighCohesion terms is the part that brings all of the settings together in to an active integration. To set this up, select the Streams option from the left hand navigation. Then on the next page press the "Create Stream" button at the top right side of the page. On the next page, complete the following settings:
  • Title - Create a title for the stream: "[SH-1201] FTP CSV x Shopify for Shipments".
  • Description - Optional, e.g. "FTP to Shopify for shipments."
  • Source - From the dropdown, select the destination "Get FTP Shipments", as created in step 2 above.
  • Transformation - from the dropdown select the private transformation file that was created in step 4 above.
  • Destination - From the dropdown, select the destination "Shopify Post Shipments", as created in step 3 above.
  • Data Type - For the data type enter: shipment
  • Active - Tick this option to activate the stream.
  • Settings - We will need to add in a stream setting for the shopify location ID (shown below), replace this with the relevant location ID from your Shopify store.
1
location_id = 1234567890
Copied!

6. Smoke test

In order to test this data stream you will need to place a Shipments file in the /outbound/shipments/received folder on the FTP. There is an examples CSV file attached below. Once you have uploaded this file to the FTP, goto the Streams list, press the view link on the [SH-1201] FTP CSV x Shopify for Shipments stream. Then from the stream view page, click on the Manual Run option from the "Actions" dropdown (top right of page).
This action will create a Job that will collect the file from the FTP and then create a Shipment event. The event will be visible on the Events list page. If all has gone correctly, the event in HighCohesion will be marked as ok and the order in Shopify will be marked as Fulfilled.

6.a Example File

Copy the data below in to a text editor and save as a CSV file. This will then create your example shipments file that can be uploaded to your FTP for the smoke test. Please remember to change the order numbers in the first column to match the test order number(s) in your Shopify store.
1
OrderNumber,CourierTrackingCode,ShipmentDate
2
"#1001","ABC23424001","29/06/2021"
3
"#1002","VEC23424433","29/06/2021"
4
"#1003","HTR23475441","29/06/2021"
Copied!

Summary

Congratulations, you are now setup and ready to enjoy a working 3PL shipments integration for Shopify.

Common Questions

Can I customise the attributes in the transformation files specific to my store? Yes! Follow this link to our guide about how to customise transformation files with specific examples.