You are currently viewing documentation for Linnworks Desktop, if you are looking for Linnworks.net documentation, click here.






Order Scripts Sample Code

Shipping Allocation

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 shipping service to an order based upon post code

This script is designed to allocate a shipping method based upon a partial match on a postal code.

Sample Script - Assign shipping service to an order based upon Post code

Assign shipping service to an order based upon packaging

This script is designed to allocate a shipping method based upon a pacakaging that has been auto allocated.

Sample Script - Assign shipping service to an order based upon Packaging

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.

Order Folder Allocation

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

Assign Order to a folder based on the Audit trail of the order

The script will iterate through order audit trail and allocate an order to a folder if the Invoice has been printed

Script Sample - Assign an order to a folder based on the Audit Trail of the Order

Order Fulfilment Location

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

Allocate an order to a Location (Not a fulfilment Centre) from any other location

The script assigns the order to a location, there are no checks to decide which orders to assign

Sample Script - Allocate an order to a location

Order Splitting

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

Order Packaging Split

Split into one package for each order item or order composite child item.

Sample Code - Split package single

Add Order Notes

Update an existing order by adding a new order note

Sample Code - Add New Order Note

Post Codes

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

USA

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

US 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

Email

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

Logging

Adding log entries to your orders.

You can add code to your open order script, that will add an entry to your orders audit trail to log that the scrip was run. below is the code you will need. 
using (SqlConnection conn = new SqlConnection(order.GetConnectionString))
{      
     conn.Open();
     linnworks.finaware.CommonData.OrderData.AddOrderLifeHistory(conn, order.pkOrderID, "SCRIPT",  "note", null, null);            
     conn.Close();
}