OrderAllocation (BETA)

Allocation Rules (BETA)

Create an allocation rule that steers which stores and warehouses the allocation engine ships an order from, with a worked example.

Beta

The allocation engine is in beta. Its behavior, settings, and API can change before general availability. To enable the engine in dev.omnium.no, please contact support.

Allocation rules tell the allocation engine which stores (warehouses) it may, may not, or should prefer to ship from - for example "small orders ship from the webshop warehouse", "bulky goods only from stores that can handle them", or "never split a click-and-collect order". Rules are the main way to put your sourcing policy for distributed order management (DOM) into the engine without changing code.

Manage rules in Configuration → Allocation → Rules. Select Add rule to start from a Blank rule, or Start from a template to begin from a common pattern - a template fills in the shape, and you set the values.

Start from a rule template

Omnium has 63 rule templates to help you get started. Each template sets up the stage, the condition, and the effects for a common sourcing policy, and leaves the values specific to your business - such as which stores, categories, or shipping methods - for you to fill in. A rule created from a template starts inactive, so you can test it before you switch it on.

CategoryTemplatesExamples
Which warehouse ships what20A category only from certain stores · Business orders from central warehouses · Never ship from certain warehouses · Prefer certain warehouses
Store and product properties7Stores exclude categories they cannot handle · Heavy goods need a capable warehouse
Distance3Prefer stores close to the customer · Only stores within a distance
Splitting into shipments7Keep the whole order in one shipment · One shipment per requested delivery date · Packages ship separately
Shipping methods6A category blocks a shipping method · Replace a shipping method
Click and collect4Pickup orders ship from the pickup store · Pickup orders prefer the pickup store
Stock and incoming supply6Never wait for a delivery · Prefer stock on hand over incoming supply
Reallocation3Reallocation uses stores with a role · Reallocation falls back to central after repeated attempts
Limits on shipments and plans7Reject shipments that are too heavy · Reject plans using too many stores · All or nothing

Use Browse templates to see them all with a short description, then adjust the rule like any other - see how a rule is built.

How a rule is built

Read a rule as one sentence: within the scope, when the condition holds, apply the effects.

SectionWhat you set there
GeneralThe name, the stage the rule runs in, its priority, whether it is active, and the message it leaves in the trace
ConditionThe condition - the facts about the order, line, product, store, or plan that must be true for the rule to act
EffectsWhat should happen when the condition holds - for example which stores to rule out, restrict to, or prefer
ScopeWhere the rule is used at all - which markets, order types, customer types, sales stores, triggers, and period

General: name, stage, and priority

FieldDescription
NameA name that says what the rule does. It identifies the rule in the rule list, the trace, and the simulator
DescriptionOptional. Notes for the people who maintain the rule
StageWhat the rule looks at - a line, a shipment, or a whole plan. See the table below
PriorityThe order the rules run in, lowest first. Exclusions and restrictions are set operations, so priority changes the order of the trace, not the result
ActiveOnly active rules are used. Rules created from a template start inactive, so you can test them first
MessageShown in the trace and to customer service when the rule excludes something. Write it so a person understands why a store was not used

The Stage decides when the rule is evaluated and which effects it can have:

StageEvaluatedUse it to
LineOnce per order line, or once per line and store when the condition uses a warehouse.* attributeNarrow or steer which stores can serve a line, and decide which lines ship together or apart
ShipmentOnce per shipment in each planReject plans with shipments that are too heavy, too far, or too large
PlanOnce per planReject plans with too many shipments or stores, or plans that leave lines unplaced

Condition: when the rule applies

The condition decides when the rule acts. Each condition compares an attribute with a value, for example Order subtotal (order.subTotal) is less than 200. Select + Condition to add a condition and + Group to add a nested group.

Each group combines its conditions and sub-groups in one of four ways:

ModeThe group holds when
All of theseEvery condition in the group holds
Any of theseAt least one condition holds
None of theseNo condition holds
Not all of theseAt least one condition does not hold

Nest groups to build combinations such as market is Norway and (category is furniture or weight is more than 30 kg).

Attributes are grouped by what they describe. The Available attributes panel beside the editor lists them all with a short description:

PrefixDescribesExamples
order.The order or cart as a wholeorder.orderType, order.subTotal, order.currencyCode, order.customerGroups, order.tags
line.The order lineline.quantity, line.shippingMethodName, line.pickupWarehouseId, line.isReserved
product.The product on the lineproduct.categoryIds, product.brand, product.tags, product.weightKg, product.properties.<key>
warehouse.The store being consideredwarehouse.id, warehouse.roles, warehouse.capabilities, warehouse.isCentralWarehouse
destination.Where the order is delivereddestination.postalCode, destination.countryCode, destination.distanceFromWarehouseKm
shipment.A shipment in a plan (Shipment stage)shipment.totalWeightKg, shipment.lineCount, shipment.distanceKm
plan.A whole plan (Plan stage)plan.shipmentCount, plan.warehouseCount, plan.isPartial
context.The run itselfcontext.trigger, context.attemptNumber, context.profileKey
external.A value provided by a connectorexternal.<connectorId>.<key>

The operators you can choose depend on the attribute's type - for example, a number offers is less than and is between, and a list offers contains any of:

OperatorMeaning
is / is notEquals or does not equal the value
is one of / is none ofEquals one of the values, or none of them
contains / contains any of / contains all ofA list attribute, such as categories or tags, holds the values
starts withText starts with the value
is more than / is at least / is less than / is at mostCompares numbers or dates
is betweenA number or date between two values, both included
is in postal code rangeA postal code inside a range written as 0150-0199, or equal to a single code
is set / is not setThe attribute has a value, or has none

Separate several values with commas. Select Compare with an attribute to compare with another attribute instead of a fixed value - for example, a store property that lists the categories the store does not handle, compared with the product's categories.

An attribute with no value only matches is set and is not set. A rule with no conditions applies to everything its scope covers.

Effects: what should happen

The effects decide what happens when the condition holds. Select Add effect to add one; a rule can have several. The list only offers the effects that belong in the rule's stage.

Effects fall into four kinds:

KindEffectsBehavior
Rule out or restrict storesDo not use these stores, Use only these stores, Central warehouses only, roles, capabilities, and stockHard: a store that is ruled out is never used for the line. A line left with no store is reported as a line that could not be placed
Steer the rankingPrefer these stores, Avoid these storesSoft: the Weight says how strongly the preference pulls. It never overrules a hard effect, and it only counts when the ranking profile includes Rule preferences
Group linesKeep these lines in one shipment, Keep apart by, Do not split this lineDecides which lines ship together or apart
Shipping methods and plansDo not use these shipping methods, Use only these shipping methods, Reject the plan, Reject plans using these storesLimits the shipping methods, or throws away plans that break a limit

Name stores directly, or switch on Select stores by a fact instead of by name to select them by a condition on the store - for example, every store whose warehouse.roles contains webshop. See all effects for the full list.

Scope: where the rule is used

The scope decides where the rule is used at all. Omnium checks the scope once per run, before any condition: a rule outside its scope does not take part in that run. An empty field means everywhere, so a rule with an empty scope applies to every order.

FieldThe rule is used when
MarketsThe order is in one of these markets
Order typesThe order has one of these order types
Customer typesThe customer is one of these types, B2B or B2C
Customer groupsThe customer is in at least one of these customer groups
Sales storesThe order was sold in one of these stores
Sales store groupsThe store the order was sold in belongs to one of these store groups
OriginsThe order has one of these origins
TriggersThe run was started for one of these reasons: InitialAllocation or Reallocation - see below
ProfilesThe plans are ranked under at least one of these profiles
PeriodThe time of the run is between Valid from and Valid until

When you fill in several fields, all of them must match. Within one field, one value is enough.

The trigger says why the engine runs:

TriggerWhen
InitialAllocationThe allocation workflow step allocates a new order
ReallocationThe allocation workflow step reallocates an order, for example after a store cancels

Simulations and manual allocations run as the trigger they stand in for, so they use the same rules as the workflow step:

  • The simulator runs as the trigger chosen under Triggers in the Allocation flow filters, and as InitialAllocation when none is chosen.
  • The Allocation API runs as the trigger in the request, InitialAllocation by default.
  • Preview and allocate on a cart or an order, and Recent orders in the simulator, run as InitialAllocation.

To make a rule behave differently in a simulation than in a real run, add a condition on context.mode instead of using the trigger.

A rule scoped to Reallocation only takes part in a simulation when you choose Reallocation under Triggers in the simulator. Leave Triggers empty unless the rule really must be limited to one kind of run.

Scope or condition?

Both can test facts about the order, so choose by what the fact describes:

  • Use the scope for facts that are the same for the whole order and that the scope has a field for - market, order type, customer type, sales store. A rule outside its scope is left out of the run before anything else is evaluated, which keeps the trace short.
  • Use the condition for everything else: facts about the line, the product, the store, or the destination, and order values that the scope has no field for, such as the order subtotal.

The example below does both: the scope limits the rule to one order type, and the condition tests the subtotal and the currency.

Example: prefer the webshop warehouse for small orders

This rule makes the engine prefer the webshop warehouse for low-value orders in NOK and SEK, so small orders are not split across or sent from physical stores when the webshop warehouse can ship them.

The General section of the rule: name, Line stage, priority 50, active, and the message

General

FieldValue
NameSend small orders from central warehouse
StageLine
Priority50
ActiveOn
MessageOrder total below 200 NOK/SEK - shipped from the central warehouse

Condition

All of these must hold:

AttributeOperatorValue
Order subtotal (order.subTotal)is less than200
Currency (order.currencyCode)is one ofNOK, SEK

The order subtotal is the sum of the order lines including tax, without shipping and fees.

Effects

EffectStoresWeight
Prefer these storesOmnium Fashion Webbutik (WebShop)1

The Condition and Effects sections: order subtotal is less than 200 and currency is one of NOK, SEK; prefer the store Omnium Fashion Webbutik with weight 1

Scope

FieldValue
Order typesDemo

Every other scope field is empty, so the rule applies in every market, for every customer type, and so on - but only to orders of the order type Demo.

What the rule does

For an order of type Demo with a subtotal below 200 in NOK or SEK, every line gets a preference for the WebShop store. Plans that ship lines from WebShop get a better (lower) score on the Rule preferences objective. The rule never rules any store out: if WebShop cannot serve a line, the engine still ships it from another store.

A preference only changes the result when the profile that ranks the plans weighs the Rule preferences objective. None of the built-in profiles do. Add Rule preferences to the profile you use in Configuration → Allocation → Settings, or use Use only these stores instead if the rule must always apply.

To make the rule a hard requirement instead, replace the effect with Use only these stores. Lines that WebShop cannot serve are then reported as lines that could not be placed, rather than shipped from somewhere else.

The rule as JSON

Edit as JSON in the rule's menu shows the same rule as JSON:

{
  "name": "Send small orders from central warehouse",
  "isActive": true,
  "priority": 50,
  "stage": "Line",
  "scope": {
    "marketIds": [],
    "orderTypes": ["Demo"],
    "customerTypes": [],
    "customerGroupIds": [],
    "salesStoreIds": [],
    "salesStoreGroupIds": [],
    "origins": [],
    "profileKeys": [],
    "triggers": []
  },
  "condition": {
    "operator": "And",
    "negate": false,
    "conditions": [
      { "attribute": "order.subTotal", "operator": "LessThan", "values": ["200"] },
      { "attribute": "order.currencyCode", "operator": "In", "values": ["NOK", "SEK"] }
    ],
    "groups": []
  },
  "effects": [
    { "type": "PreferWarehouses", "values": ["WebShop"], "weight": 1.0 }
  ],
  "message": "Order total below 200 NOK/SEK - shipped from the central warehouse",
  "tags": ["low-value"]
}

Test the rule

Before you activate a rule, check what it does:

  • Validate in the rule's menu checks the rule without saving it, for example that every condition has a value and that each effect belongs in the rule's stage.
  • Test this rule runs one order through the engine with this rule alone, so the answer is about this rule. Enter an order number and select Run test. The result says The rule matched or The rule did not match, followed by the plan.
  • The allocation simulator runs an order with all active rules, and the Allocation flow tab shows where the rule acted. Use Recent orders in the simulator to see how a rule changes the choice of warehouse across many orders.

All effects

EffectStagesWhat it does
Do not use these storesLineRemoves the named stores from the choices for the line
Use only these storesLineNarrows the choices to the named stores. Two restrictions leave only what both allow
Store must have all of these rolesLineKeeps only stores that have every store role named here
Store must be able to handle thisLineKeeps only stores that list every capability named here
Central warehouses onlyLineKeeps only stores marked as central warehouses
Default warehouse onlyLineKeeps only the market's default warehouse. A market with none configured is left alone
Goods must already be in the storeLineKeeps only stores that can serve the line from stock they already hold
Do not use these shipping methodsLineRemoves the named shipping methods from the shipment the line ends up in
Use only these shipping methodsLineNarrows the shipment to the named shipping methods
Prefer these storesLineCounts in favour of the stores in the ranking, without ruling anything out
Avoid these storesLineCounts against the stores in the ranking, but they can still be used
Keep these lines in one shipmentLineThe lines the rule matches are placed together or not at all
Keep apart byLineLines whose values for the named attributes differ never share a shipment, even from the same store
Do not split this lineLineThe whole quantity comes from one store
Reject the planShipment, PlanThrows the plan away
Reject plans using these storesPlanRejects the plan, and the engine tries again without the named stores

Store effects name stores directly, or select stores by a fact with Select stores by a fact instead of by name - for example every store whose warehouse.roles contains a given role.

How effects combine

  • Rules run in priority order, lowest first. Exclusions and restrictions are set operations, so priority changes the order of the trace but not the result.
  • Every exclusion takes its stores away, and two restrictions leave only what both allow.
  • A line left with no store is reported as a line that could not be placed - it is not quietly dropped.
  • Preferences add up and only affect the ranking.
  • A rejected plan is retried without the stores that caused it.