Dynamic Discount Value Builder

The dynamic discount value builder defines how the discount value is calculated. 

Contents

  1. Dynamic Discount Value Builder Overview
  2. Formula Builder Overview
  3. Expression Output
  4. Operand reference
  5. Operator reference

Dynamic Discount Value Builder

Instead of using a static value for a given discount, you can also create formulas with mathematical and logical operators and assign a dynamic discount value. Discounts will be calculated during redemption based on the provided formula and metadata values. 

The formula builder requires a static fallback value in case the dynamic discount value cannot be calculated from the given parameters in the formula.

You can either use the Formula builder utility with step-by-step dialogs that you fill out to build the formula from element building blocks or the Expression output with operators and operands. 

The dynamic discount value applies to the following discount types:

  • Amount
  • Percentage
  • Fixed amount
  • Unit

and can be used when creating coupon campaigns, in-cart promotions, and referral codes.


Formula Builder

You can use the Formula builder utility with step-by-step dialogs to build the formula from element building blocks.  

First, select the Plus icon next to the discount value.

Then, begin to build your formula using the formula builder by choosing a type of operand followed by an operator. Use the X icon to delete a number or expression and the + icon to remove the number or expression. 

To review your expression, choose Expression output

Click Save once you have finished defining your dynamic discount formula.


Expression Output

You can view and edit the dynamic discount formula through a mathematical expression using operands and operators. Click  Save once you have finished defining your dynamic discount formula. 

Expression Output


Operand Reference

You can see the discount values that you can create using different discount operands in the following table. 

Operand
Definition Example
Number
Value is a Number. 2

Order metadata
Value is an order metadata attribute of type Number

Order Metadata Operand Example in Formula Builder

ORDER_METADATA("day_of_week")


Voucher metadata
Value is a voucher metadata attribute of type  Number
Voucher Metadata Operand Example in Formula Builder

REDEEMABLE_METADATA("active_on_calendar_month")


Customer metadata
Value is a customer metadata attribute of type Number. Customer Metadata Operand Example in Formula Builder

CUSTOMER_METADATA("customer_life_time_value")


Redemption metadata
Value is a redemption metadata attribute of type Number. Redemption Metadata Operand Example in Formula Builder

REDEMPTION_METADATA("store_list")


Publication metadata
Value is a publication metadata attribute of type Number Publication Metadata Operand Example in Formula Builder

PUBLICATION_METADATA("year")





Brackets
Groups expression elements together; i.e. adds parenthesis to your formula. Brackets Operand Example in Formula Builder

(10 - ORDER_METADATA("number_of_store_visits"))




Min
Lowest value in a range MIN(PUBLICATION_METADATA("year");   CUSTOMER_METADATA("customer_life_time_value"))



Max
Highest value in a range MAX(PUBLICATION_METADATA("year");   CUSTOMER_METADATA("customer_life_time_value"))



Power
A number raised to a power; defines the base and exponent.

POW(ORDER_METADATA("number_of_store_visits");2)




If
Value based on a logical expression; defines the logical test value, value if expression is true and value if expression is false.

IF(ORDER_METADATA("number_of_store_visits") > 5;10;3)





Default
Returns first non-null value of range.

DEFAULT_TO(REDEMPTION_METADATA("store_list") / 2;5)


Operator reference

Here are the discount formula operators you can choose from. 

Operand
How does it work?
Context Use case
Add
+




Adds numbers or expressions.
  • Standard formula
Example with missing metadata property defaulting to fallback value

CUSTOMER_METADATA("number_of_store_visits") + REDEEMABLE_METADATA("active_on_calendar_month")
Missing metadata property: number_of_store_visits

Fallback value: 10%
Subtract
-
Subtracts numbers or expressions.
  • Standard formula
  • Logical expression
Give customer a percent off for every year since they first became a customer.

PUBLICATION_METADATA("year") - CUSTOMER_METADATA("customer_life_time_value")
year: 2022
customer_life_time_value: 2012

Calculated dynamic discount value: 10%
Fallback value: 10%
Multiply
x
Multiplies numbers or expressions.
  • Standard formula
  • Logical expression
Give customer a discount proportional to the day of the week; assuming i.e. days of the week are defined as: 

Sunday - 0
Monday - 1
Tuesday - 2
Wednesday - 3
Thursday - 4
Friday - 5
Saturday - 6

ORDER_METADATA("day_of_week") x 2
day_of_week: 5

Calculated dynamic discount value: $10
Fallback value: $10
Divide
÷
Divides numbers or expressions.
  • Standard formula
  • Logical expression
Give customer an eighth for every month the customer was active.

CUSTOMER_METADATA("customer_months_active") ÷ 8
customer_months_active: 8

Calculated dynamic discount value: $10
Fallback value: $10
Remainder after division
%
This is a modulo operation; returns the amount "left over" after dividing one number or expression by another.
  • Standard formula
  • Logical expression
Give customer a certain number of free items based on a custom formula.

REDEEMABLE_METADATA("active_on_calendar_month") % REDEMPTION_METADATA("allowed_free_units")
active_on_calendar_month: 10
allowed_free_units: 9
remainder: 1

Calculated dynamic discount value:  1 Free item
Fallback value:  1 Free item

Greater than
>
Logical operator returns the Value if true if the value on the left is greater than the value on the right, otherwise returns the Value if false.
  • Logical expression
Give customer 20% off every time they make a purchase after their 10th store visit; otherwise the customer receives a standard 3% discount.

IF(CUSTOMER_METADATA("number_of_store_visits") > 10;20;3)
Less than
<
Logical operator returns the Value if true if the value on the left is less than the value on the right, otherwise returns the Value if false.
  • Logical expression
Give customer 3% off each store visit until their 9th store visit; then beginning from their 10th store visit, give the customer a 20% discount.
 
IF(CUSTOMER_METADATA("number_of_store_visits") < 10;3;20)
Equal to
=
Logical operator returns the  value if true if the value on the left is equal to the value on the right, otherwise returns the Value if false.
  • Logical expression
Give customer 50% off on their 50th store visit.

IF(CUSTOMER_METADATA("number_of_store_visits") = 50;50;0)
And Two or more relations can be logically joined using the logical operator AND. Both relations must be true for the complex expression to be true.
  • Logical expression
Give customer 20% off every time they make a purchase after their 10th store visit AND the customer makes a purchase on a Friday; otherwise the customer receives a standard 3% discount.

IF(CUSTOMER_METADATA("number_of_store_visits") > 10 AND ORDER_METADATA("day_of_week") = 5;20;3)
Or Two or more relations can be logically joined using the logical operator OR. If either relation is true, the complex expression is true.
  • Logical expression
Give customer 20% off every time they make a purchase after their 10th store visit OR the customer makes a purchase on a Friday; otherwise the customer receives a standard 3% discount.

IF(CUSTOMER_METADATA("number_of_store_visits") > 10 OR ORDER_METADATA("day_of_week") = 5;20;3)
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us