Quantifiers in Order Rules

This article describes the use of quantifiers in DropStream order rules.



In order to create rules that do not apply to the whole order but only to some items in the order, DropStream rule language includes quantifiers all, any and no. Using quantified conditions will allow you to create more specific or granular order rules, and in this way further streamline your order fulfillment workflow.

For example, you may want to require that if any of the items in an order is oversize, then the whole order is shipped via FedEx Ground. 

Quantifiers have the following meanings in DropStream:

  • all order_items match conditions -  universal quantifier; the rule containing it applies if all items in the order meet the condition.
    • E.g. If all items have SKUs that contain the word promo then apply 15% discount to the order.
  • any order_items match conditions -   existential quantifier; the rule containing it applies if at least one item in the order meets the condition.
    • E.g. if any of the items in the order is oversize then ship the whole order via FedEx Ground. 
  • no order_items match conditions -   negative quantifier; the rule containing it applies if none of the items in the order meet the condition.
    • E.g. if the order contains no items that should not be gift-wrapped, then add the shipping description "Fragile"to the order.


We demonstrate the use of quantifiers by creating a rule for the second example above that contains an existential quantifier (if at least one order item is oversize, ship the order via FedEx Ground). 

  1. Open the desired store.
  2. Go to the Rules tab.

    DropStream - Rules

  3. Click +Add rule.

    DropStream - Add a rule

  4. Give your rule a descriptive name and click +Add Action.

    DropStream - Name the rule

  5. Select an action to perform from the dropdown, e.g. Condition.

    DropStream - Select an action

  6. Select a quantified order item list from the dropdown next to IF. For this example we will be using any (any_order items match the condition).

    DropStream - Select a quantifier

  7. In the dropdown menus next to your operator, select Compare Order Item Attribute.

    DropStream - Compare order item attribute

  8. Then determine the condition that you want to have met. In this case we want to check if the size description of any order item contains the word "oversize".

    DropStream - Define the condition

  9. Click the blue +Add Action  button in the active rule window.

    DropStream - Add an action

  10. Select the action to perform from the dropdown menu. For our example, we will select Shipping Transformer.

    DropStream - Shipping transformer

  11. From the dropdown menu, select the Ship via value that meets your needs. For our example, we will select FedEx Ground.

    DropStream - Ship via

  12. To finish, first click OK and then click Save changes.

    DropStream - Save changes

Notes on use

In DropStream, quantifiers can only be applied to order items, not to orders because DropStream's rule engine applies rules to each order separately. Because of that, quantified conditions can only reference attributes of order items, not attributes of orders.

Quantified conditions can be combined with logical operators to form complex conditions. Such conjuncts behave like other complex, boolean statements, and can reference both the attributes of order items and the attributes of orders, although quantifiers can still be used with order items only.

Quantified conditions cannot contain other quantified conditions, so "nested quantification" is not allowed in DropStream. This is also not needed because quantifiers in DropStream can only be applied to order items, not to attributes or attribute values, and repeating quantifiers for the same object results either in a tautology (if the same quantifiers are used) or in a contradiction (if different quantifiers are used). 

Source code

In the rule source code used in the Advanced Editor, quantifiers are represented in infix notation as follows:

  • all order_items match conditions → order has all order_items with (order_item.attribute comparison_operator value)
  • any order_items match conditions → order has any order_items with (order_item.attribute comparison_operator value)
  • no order_items match conditions → order has none order_items with (order_item.attribute comparison_operator value)

Here is a example rule that encodes the quantifier examples presented above.

rule "Quantified condition"
order has all order_items with (order_item.sku contains "promo")
set order.discount_amount to 15.0
order has any order_items with (order_item.size_description contains "oversize")
set order.shipping_carrier_name to "FDX"
set order.shipping_warehouse_code to "FDX G"
set order.shipping_carrier_service_level to "Fedex Ground"
order has none order_items with (order_item.gift_wrap blank)
set order.external_shipping_description to "Fragile"

Finally, we include a rule example that contains both quantifiers and boolean operators.

In the first statement, the quantifier any has scope over the disjunction (OR). In the second  statement, the disjunction has scope over the two quantifiers. The rule rejects orders where at least one of the order items is named the same as the shipping companies DHL or FedEx. 

rule "Coordinated quantifiers"
order has any order_items with (order_item.name is "DHL" or order_item.name is "Fedex")
reject order
order has any order_items with (order_item.name is "DHL") or order has any order_items with (order_item.name is "FedEx")
reject order
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request



Please sign in to leave a comment.