DropStream's rules engine is a powerful tool that enables you define and automate custom integration behaviors. Like all powerful tools, it should be used safely.
When writing a custom rule, you can use conditional statements for testing purposes, so that your new rules do not affect your live orders until testing is complete. We call this approach safe-ifying.
The following is an example of a
when statement that safely tests a custom rule behavior. This behavior should not yet be applied to live orders; for now, it should only run when certain test conditions are satisfied.
order.shipping_first_name starts_with "testrule"
#Custom code here
when statement should be placed immediately after a rule definition, i.e. rule name. The test code will only run when the first name of the shipping recipient begins with "testrule", e.g., testrule-1, testrule-2, etc.
When the testing of the custom rules is complete, the
when statement and its corresponding
end statements can be removed, leaving only the main code.
Here's another example of safe-ifying a custom rule for testing:
rule "Testing Safe-ify" when order.shipping_first_name starts_with "testrule" then for order_items in order when order has any order_items with (order_item.sku starts_with "SKU-C") then add 1.0 item to order_items in order set item.sku to "SKU-A" end add 1.0 item to order_items in order set item.sku to "SKU-B" end end end end end
Note: Be safe while working with the rule engine, and use this safe-ify technique to protect your current integration process while testing new rules.