Skip to content
← Back to Index

target

Keyword

 target(filter: (value) => boolean | nothing): [Target] 

The target keyword selects which parts of an order should be affected by a discount effect. It takes a filter function that receives each order line and delivery, returning true for items that should be targeted.

The result is passed to percentage or absolute as the first argument.

Availability

PromotionRuleReactor

Filter Function

The filter function receives each targetable entity on the order. You can use is pattern matching to distinguish between entity types:

  • Delivery — a shipping/delivery entity
  • OrderLine — an individual order line

Examples

Target all deliveries (free shipping)

filtrera
from percentage(target(e => e is Delivery), 100%)

Target specific order lines

filtrera
from absolute(target(e => e is OrderLine and e.productNumber == 'GIFT-WRAP'), 0)

Target by dynamic field

filtrera
from percentage(target(e => e is OrderLine and e.dynamic->'category' == 'clearance'), 30%)

Target everything

To target the entire order (all order lines and shipping), use the order symbol directly instead:

filtrera
from percentage(order, 10%)

See Also

© 2024 Hantera AB. All rights reserved.