Before Create Order Scripts

Updated 1 month ago by Cory M.

The "Before Create Order" script type executes just before an order is created. This script allows you to transform the order options, address, and items or reject the order entirely.

How to Create a Before Create Order Script

  1. Navigate to System > Scripts.
  2. Click Create New Script at the top right.
  3. Select the Merchant to which the script will be applicable or "--All Merchants--" to have the script apply to all merchants.
  4. Enter a brief description for the script so you can easily identify it. This may also appear in the order history.
  5. Select Before Create Order as the Type.
  6. Change the Is Active field to Yes if you wish to use the script after it is saved, or leave it as No to disable it for now.
  7. Set a Sort Order if using multiple scripts to control the order in which the scripts are applied. Lower numbers will run before script with higher numbers.
  8. Click Save.

Editor Error Handling

If the script contains errors or invalid 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.

Runtime Errors

If any errors occur during the execution of the script and are not captured and handled within the script they will cause the order submission to fail with an error describing the script which threw the error, the line number and the error message. These will be logged and visible at the bottom of the Edit Script page. Once the script is saved these errors will be cleared so that you can easily determine if new errors are still occurring.

The editor is able to detect basic syntactical errors, but it is still possible to introduce runtime errors. For example, a common issue is setting or referencing a property of an "undefined" expression:


How did we do?