Ready to Ship Time Scripts

Updated 1 month ago by Colin Mollenhour

This script type is executed when an Order is created and when an Order changes from not-"Ready to Ship" to "Ready to Ship". The script may not modify any Order attributes, it can only return a timestamp object that will be used in place of the default current timestamp. If no value is returned the current timestamp is assumed.

The variables defined in the context of these scripts are:

  • order - provides all of the order information
  • ShipStream - provides methods for creating new timestamp objects

Other methods available are:

  • print - add a message to the order history

Script Priority

If there are multiple Ready to Ship Time scripts defined for the same Merchant, the first one to return a valid timestamp will be used and further scripts will not be executed. Use the Sort Order to ensure that the most important scripts are run first and do not return a value if you want to allow later scripts to run.

Example

This script causes the Ready To Ship time for "crossdock" orders to always be the next day, or for orders that were previously backordered to be delayed by two hours, and otherwise uses the default behavior.

if (order.options.shipping_method === 'external_crossdock') {
return ShipStream.date('tomorrow', 'America/New_York')
} else if (order.old_status === 'backordered') {
return ShipStream.now().modify('+2 hours')
}
else {
return ShipStream.now()
}

Here is an example where the Ready to Ship time is set as 3 hours earlier than the actual time to help ensure they are fulfilled the same day.

if ((order.options.order_ref||'').match(/-VIP$/)) {
print('VIP order given 3 hours grace period for cut-off.')
return ShipStream.now().modify('-3 hours')
}


How did we do?