Order Scripts Sample Code



Assign Shipping Service to an order

In this script we check source and the country of an order, if its AMAZON or EBAY, then we evaluate total cost and weight of an order and assign postal service accordingly.

Sample Script - Assign Shipping Service to an order

Assign shipping service to an order based on the prefered shipping method of order item

This script will go through all order items and check the prefered shipping method for the item, grab the last item in the order and assign order to the service. Then check if the order value is greater than 100 and then assign to Recorded Shipping.

Sample Script - Assign shipping service to an order based on the prefered shipping method of order item

Assign Order to a folder based on extended properties of an item

The script will iterate through order item and allocate an order to a folder based on the extend property of an stock item. For example if you put Extended property for a stock item with the name To Folder and property value is Some Special Folder, when Linnworks sees this stock item in the order it will allocate the order to folder Some Special Folder.

Script Sample - Assign an order to a folder based on the extended property of an order item

US State name change to state code

The script changes the US state name to a state code. You can add your own variations of state names and most common misspellings to the dictionary in StateReplace replace method.

Script Sample - US State name change to state code

United States state Tax Recalculation

The script check if the state of the shipping address is CA (California) and sets the tax rate to 8.5%

Sample Script - United States state Tax Recalculation

Allocate an order to a fulfilment center location from any other location

The script checks whether fulfilment center Fulfilment Center Name has sufficient stock for all order items, if yes then the order is automatically allocated to the fulfilment center

Sample Script - Allocate an order to a fulfilment center location from any other location

Send a single email to Drop Shipper for an order

The script checks if an order is allocated to a specific fulfilment center (in this case fulfilment id "AAA1DC7C-1740-484C-B020-E95F78678931" - use Debug to find out the Id of the fulfilment center location), the script will itterate through all order items and compile an email body to be sent to a drop shipper. Then sends the email immidiatly using SMTP details specified in the SendEmailNow command.

Sample Script - Send a single email to Drop Shipper for an order

Splitting an order based on available stock level - checking only specific folder and then moving to another folder

This script does the following,

1) only orders that are in Check For Split folder will be considered in this script, this is filtered in Filter query

2) the script will get availability levels for the order items, it will also exclude all orders in Check For Split folder, in order to get accurate available quantity

3) if there are enough stock to fulfil ALL items (and all the same items in all other orders),

- the order will be moved to Ready folder

4) if order can be fulfilled partially it will be split out into two orders

- the new order will be moved to Ready folder

Note: This script is using filtering to only get orders that are allocated to folder Check For Split and only those orders that have at least one or more item availablity >=0

Sample Code - Splitting an order based on available stock level - checking only specific folder and then moving to another folder

Reformat UK Post Code such that it's uppercase and contains a space in the correct place.

This script does the following:

1) Sets the postcode to upper case

2) Inserts a space in the correct place

Sample Code - UK Post Code formatting

Assign postal service based upon post code.

This script does the following: Checks against the postcode of the order and if found within list will allocate the postcode based upon the condition provided.

Sample Code - Assign postal service based upon post code.