Filter actions decide whether an order or a line item goes on to the warehouse. Use them in a store’s Order Import rules to stop lines or whole orders you don’t want fulfilled. Rules in a hook run top to bottom.
Which action to use
| Action | What happens | Order status |
|---|---|---|
reject order_line (inside for order_lines in order) |
The line stays on the order, listed under Excluded items, and is not sent to the warehouse. The rest of the order carries on. | Unchanged, unless every line is rejected (see below) |
reject order |
The order is not sent to the warehouse, and no later rules run for it. | Skipped (“Filtered by rules”) |
archive order |
The order is archived and not sent to the warehouse. | Archived |
fail order with "<message>" |
The order stops with an error that someone has to deal with. The order shows Rule '<rule name>' explicitely rejected order: <message>. |
Error |
accept order and accept order_line let a record continue. Every record is accepted unless a rule rejects it, so you rarely need accept.
When every line is rejected
If every line on an order is rejected, the order becomes Skipped, the same as reject order. This is checked once, after all of the store’s Order Import rules have run. An order with at least one line left carries on with that line.
Reject a line
rule "Reject a SKU"
for order_lines in order
when
order_line.sku is "<SKU>"
then
reject order_line
end
end
end
On the order page, rejected lines are listed under Excluded items (“Excluded items are not processed”).
Reject an order
rule "Reject orders to <country>"
when
order.shipping_address.country is "<2-letter code>"
then
reject order
end
end
DropStream converts a recognized country name or 3-letter code to the 2-letter code before rules run, so compare against "US", "CA", and so on.
To allow only certain countries and reject the rest:
rule "Allow only US and Canadian shipments"
when
not (
order.shipping_address.country is "US"
or order.shipping_address.country is "CA"
)
then
reject order
end
end
Use this not (... or ...) form rather than is_not ... and is_not .... A comparison against an empty field is false for both is and is_not, so the is_not form would let orders with no country through.
Build a line filter in the visual editor
- In the left sidebar, click Automation › Rules, then New Rule. Choose the Store, set Hook to Order Import, and click Continue to editor.
- Click Start Building (on some accounts, Build manually). In Add Statement, choose Flow Control › For Each, then click Add Statement. The loop iterates over the order’s lines.
- Click inside the loop (“Click to add statements”) and add Flow Control › When. In the Configuration panel, under Conditions, pick the order line field
sku(orname), choose the operator, and enter the value. - Click the THEN area and add Order Actions › Reject. In its panel, change Model from Order to Order Line. If you leave it at Order, the rule rejects the whole order.
- Name the rule (pencil icon), then click Save. The header shows Unsaved until you do.
- Open the More actions menu and click Activate. New rules are created Inactive.
For a whole-order rule, skip the For Each step and leave Model at Order.
Before activating, try the rule against a real order on the Test tab.
Things to know
-
A rejected line is still on the order. Other rules that count or test lines still see it. To ignore rejected lines in a condition, add
order_line.included?. - Rule changes apply to orders processed afterwards. For orders already imported, open the order and click Actions › Reset, or select orders on the Sales Orders list and choose Reset from More Actions. Reset puts the order and its lines back as they were before rules ran, so excluded lines come back, and then runs the rules again. Reset is refused for orders with shipments, canceled orders, and orders older than 6 months. See Reset Orders.
- An order already sent to the warehouse isn’t changed by a later rule. DropStream doesn’t resend it with different lines.
-
Other models can be filtered in their own hooks, for example
reject sales_order_return_itemin a Return Import hook.
default accept and default reject
default accept and default reject set a fallback outcome for records in a rule. If you use one, test the rule against real orders on the Test tab before activating it, and check that orders you expect to keep aren’t rejected. The examples on this page use not (...) conditions instead.
For more examples, see Rules for Imported Orders.
Comments
Please sign in to leave a comment.