Scripting Basics

Cory M. Updated by Cory M.

ShipStream utilizes an embedded JavaScript interpreter in many places to allow the user to define advanced business logic and customizations. The interpreter is an implementation of the 6th edition of ECMAScript known commonly as ES6 or ES2015.

See the more detailed guides for additional information about writing specific types of scripts:

Javascript Editor

On pages where a user may define a script the script is submitted in a text field that has some basic syntax highlighting and validation features.

Syntax Errors

If the script contains syntactical errors code then an indicator will appear on the line number where the error is detected. Hover your cursor over the icon to see more information. All errors and warnings must be addressed before the script can be saved.

Logical Errors

The built-in editor can detect many potential problems which are not syntactical. It is recommended not to ignore these warnings as they very likely are an indicator that the script will throw a logical error or not behave as expected.

Debugging

All scripts support a print() function. This can take any arguments of any type and will cause the interpreter to "output" some information. This information will typically be captured by ShipStream and reported in an order's history or some other location relevant to the scope of the script. In general, use the print statement to provide the end users with useful information about what affect your script had or to debug your scripts.

if (order.address.country != 'MX') {
order.options.shipping_method = 'fedex_INTERNATIONAL_ECONOMY'
print('Forced order to Mexico to be shipped via FedEx International Economy')
}

How did we do?

Before Create Order Scripts

Contact