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. Cheapest & Most Expensive Order Item
  6. Operator reference
    1. Number operators
    2. String operators
    3. Date operators
    4. Complex expression operators
  7. Nested Formulas

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
Text Value is a String. Unique string of alpha numeric characters.

Order metadata
Value is an order metadata attribute of type Number or String.

Order Metadata Operand Example in Formula Builder

ORDER_METADATA("day_of_week")


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

REDEEMABLE_METADATA("active_on_calendar_month")


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

CUSTOMER_METADATA("customer_life_time_value")


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

REDEMPTION_METADATA("store_list")


Publication metadata
Value is a publication metadata attribute of type Number or String 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 Operand Example in Formula Builder

MIN(PUBLICATION_METADATA("year"); CUSTOMER_METADATA("customer_life_time_value"))




Max
Highest value in a range MAX Operand Example in Formula Builder

MAX(PUBLICATION_METADATA("year"); CUSTOMER_METADATA("customer_life_time_value"))




Power
A number raised to a power; defines the base and exponent. Power Operand Example in Formula Builder

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 Operand Example in Formula Builder

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





Default
Returns first non-null value of range. Default Operand Example in Formula Builder

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

Order item price Returns order item price. For each item you can get a particular discount, e.g. (order item price) x 0.01 + 1, if item price is 6.00, the discount is 1.06, if item price is 10.00, the discount is 1.10.

Order Item Price Operand Example in Formula Builder

ORDER_ITEM_PRICE

Order item amount Returns order item amount; for stacked discounts, returns the original amount without any modifications due to other discounts.

Order Item Amount Operand Example in Formula Builder

ORDER_ITEM_AMOUNT

Order item subtotal Returns order item subtotal; for stacked discounts, each additional discount is based on the result obtained after calculating the previous discount.

Order Item Subtotal Operand Example in Formula Builder

ORDER_ITEM_SUBTOTAL

Order item units quantity Returns order item quantity.

Order Item Units Quantity Operand Example in Formula Builder

ORDER_ITEM_UNITS_QUANTITY

Order item metadata Returns order item metadata.

Order Item Metadata Operand Example in Formula Builder

ORDER_ITEM_METADATA("Size")

Cheapest order item price Returns the price of the cheapest line item in the order. Read more.

Cheapest Order Item Price Operand Example in Formula Builder

CHEAPEST_ORDER_ITEM_PRICE


Cheapest order item amount Returns the amount of cheapest line items in the order; for stacked discounts, returns the original amount without any modifications due to other discounts. Read more.

Cheapest Order Item Amount Operand Example in Formula Builder

CHEAPEST_ORDER_ITEM_AMOUNT


Cheapest order item subtotal Returns the subtotal of cheapest line items in the order; for stacked discounts, each additional discount is based on the result obtained after calculating the previous discount. Read more.

Cheapest Order Item Subtotal Operand Example in Formula Builder

CHEAPEST_ORDER_ITEM_SUBTOTAL

Cheapest order item units quantity Returns total units of cheapest order line items. Read more.

Cheapest Order Item Units Quantity Operand Example in Formula Builder

CHEAPEST_ORDER_ITEM_UNITS_QUANTITY

Cheapest order item metadata Returns cheapest order item metadata of type Number or String. Read more.

Cheapest Order Item Metadata Operand Example in Formula Builder

CHEAPEST_ORDER_ITEM_METADATA("Size")

Most expensive order item price Returns the price of the most expensive line item in the order. Read more.

Most Expensive Order Item Price Operand Example in Formula Builder

MOST_EXPENSIVE_ORDER_ITEM_PRICE

Most expensive order item amount Returns the amount of most expensive line items in the order; for stacked discounts, returns the original amount without any modifications due to discounts. Read more.

Most Expensive Order Item Amount Operand Example in Formula Builder

MOST_EXPENSIVE_ORDER_ITEM_AMOUNT

Most expensive order item subtotal Returns the subtotal of most expensive line items in the order; for stacked discounts, each additional discount is based on the result obtained after calculating the previous discount. Read more.

Most Expensive Order Item Subtotal Operand Example in Formula Builder

MOST_EXPENSIVE_ORDER_ITEM_SUBTOTAL

Most expensive order item units quantity Returns total units of most expensive order line items. Read more.

Most Expensive Order Item Units Quantity Operand Example in Formula Builder

MOST_EXPENSIVE_ORDER_ITEM_UNITS_QUANTITY

Most expensive order item metadata Returns most expensive order item metadata of type Number or String. Read more.

Most Expensive Order Item Metadata Operand Example in Formula Builder

MOST_EXPENSIVE_ORDER_ITEM_METADATA("Size")

Order amount Returns order total value, whole cart value.

Order Amount Operand Example in Formula Builder

ORDER_AMOUNT

Order items quantity Returns item count.

Order Items Quantity Operand Example in Formula Builder

ORDER_ITEMS_QUANTITY

Order units quantity

Returns sum of units ordered.

Order Units Quantity Operand Example in Formula Builder

ORDER_UNITS_QUANTITY

Voucher redemption quantity

Returns voucher's redemption limit.

Voucher Redemption Quantity Operand Example in Formula Builder

VOUCHER_REDEMPTION_QUANTITY

Voucher redeemed quantity

Returns the number of times the voucher was redeemed.

Voucher Redeemed Quantity Operand Example in Formula Builder

VOUCHER_REDEEMED_QUANTITY

Voucher published count

Returns the number of times the voucher was published. This value will be either 0 or 1, so this parameter can be used as a security check. For example, if the voucher is assigned (published), then the customer gets a discount, otherwise, no discount.

Voucher Publish Count Operand Example in Formula Builder

VOUCHER_PUBLISH_COUNT

Voucher start date

Returns the voucher's start date.

Voucher start date Operand Example in Formula Builder

VOUCHER_START_DATE

Voucher expiration date

Returns the voucher's expiration date.

Voucher expiration date Operand Example in Formula Builder

VOUCHER_EXPIRATION_DATE

Promotion tier start date

Returns the promotion tier's start date.

Promotion tier start date Operand Example in Formula Builder

PROMOTION_TIER_START_DATE

Promotion tier expiration date

Returns the promotion tier's expiration date.

Promotion tier expiration date Operand Example in Formula Builder

PROMOTION_TIER_EXPIRATION_DATE

Customer's birthdate

Returns the customer's birthdate.

Customer's Birthdate Operand Example in Formula Builder

CUSTOMER_BIRTHDATE

Cheapest & Most Expensive Order Item

How are the cheapest and most expensive order items found if there are multiple items with the same price?

Cheapest Order Item Most Expensive Order Item

This is how the cheapest order item is defined.

This is how the most expensive order item is defined.

1
First, the formula tries to find the order item with the cheapest price. If there is one item, then the formula returns this item, otherwise it proceeds to step 2.
2
If there are  n items that have the same cheapest price, from this  n the formula finds items with the lowest subtotal. If there is only one item —  the formula returns this item, otherwise if there are many items, it proceeds to step 3.
3
Finally, it returns the first item from the list of cheapest items with the lowest subtotal.
1
First, the formula tries to find the order item with the most expensive price. If there is one item, then the formula returns this item, otherwise it proceeds to step 2.
2
If there are  n items that have the same most expensive price, from this  n the formula finds items with the lowest subtotal. If there is only one item — the formula returns this item, otherwise if there are many items, it proceeds to step 3.
3
Finally, it returns the first item from the list of most expensive items with the lowest subtotal.

Operator reference

Number Operators

Here are the discount formula operators you can choose from for properties of Number type. 

Operand
How does it work?
Use case
Add
+




Adds numbers or expressions.

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. 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.

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.

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

Modulo
%
Returns remainder after division, i.e. returns the amount "left over" after dividing one number or expression by another.

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. Give customer 20% off every time they make a purchase after their 10 th 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. Give customer 3% off each store visit until their 9 th 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. Give customer 50% off on their 50 th store visit.

IF(CUSTOMER_METADATA("number_of_store_visits") = 50;50;0)


String Operators

Here are the discount formula operators you can choose from for properties of String type. 

Operand
How does it work?
Use case
Is Logical operator returns true if the strings are equal and false otherwise. Give customer $20 off every time they make a purchase by following a link from Facebook; otherwise the customer receives a discount equal to their age.

IF(CUSTOMER_METADATA("acquisition_channel") is "Facebook";20;CUSTOMER_METADATA("age"))

Is not Logical operator returns true if values are NOT equal and false otherwise. Give customer 10% off every time they make a purchase except when they are acquired through Twitter; otherwise the customer receives a 3% discount.
 

IF(CUSTOMER_METADATA("acquisition_channel") isNot "Twitter";10;3)

Contains Logical operator returns true if the value on the left contains the value on the right. Give customers living in California 3 free coffees.

IF(CUSTOMER_METADATA("location") contains "California";3;0)

Starts with Logical operator returns true if the value on the left starts with the value on the right. Give customer buying at one of our stores on the Jersey shoreline a 15% discount.

(IF(REDEMPTION_METADATA("location_id") startsWith "Jersey_Shoreline_store_";15;0))

Ends with Logical operator returns true if the value on the left ends with the value on the right. Give customer 50% off if they receive a code via SMS; otherwise they will receive a 35% discount.

IF(PUBLICATION_METADATA("publication_method") endsWith "_sms";50;35)


Date Operators

Here are the discount formula operators you can choose from for properties of Date type. 

Operand
How does it work?
Use case
Days since Returns number of days from the start date (variable) to the end date (current date), but not including the end date.

YYYY-MM- DDCurrent
- YYYY-MM-DDVariable

# days excluding end date

Incentivise customers to make another purchase after they make an order by creating a discount that depreciates with the number of days since they last made a purchase.

IF(DAYS_SINCE(CUSTOMER_METADATA ("date_last_purchase")) < 31;30 / DAYS_SINCE(CUSTOMER_METADATA ("date_last_purchase"));0)

Months since Returns number of months from the start date (variable) to the end date (current date) excluding the end date.

YYYY- MM-DDCurrent
- YYYY-MM-DDVariable

# months excluding end date
If you are subscribed for more than 12 months, you'll get a discount of 20%. Otherwise, you'll get 10%.
 

IF(MONTHS_SINCE(CUSTOMER_METADATA ("date_subscribed")) > 12;20;10)

Years since Returns number of years from the start date (variable) to the end date (current date) excluding the end date.

YYYY-MM-DDCurrent
- YYYY-MM-DDVariable

# years excluding end date

Give customers an increasing discount based on the number of years they are a customer.

YEARS_SINCE(CUSTOMER_METADATA ("acquisition_date"))

Get a discount equal to your age!

YEARS_SINCE(CUSTOMER_BIRTHDATE)

Days until Returns number of days from the start date (current date) to the end date (variable) excluding the end date.

YYYY-MM- DDVariable
- YYYY-MM-DDCurrent

# days excluding end date

Early bird scenario - If you want customers to buy the items sooner, you can influence the discount based on the number of days from/to a specific date. 

A decreasing percentage discount that goes to zero at the voucher expiration date. For each day until the expiration date, the customer will get 2 percent off.

DAYS_UNTIL(VOUCHER_EXPIRATION_DATE) * 2 

Months until Returns number of months from the start date (current date) to the end date (variable) excluding the end date.

YYYY- MM-DDVariable
- YYYY-MM-DDCurrent

# months excluding end date
Buy six months or more prior to new year's eve and pay 15% less! Otherwise you'll get 5% off. Here, the expiration date would be set to new year's eve.

IF(MONTHS_UNTIL(VOUCHER_EXPIRATION_DATE) > 6;15;5)

Day of month Returns number of day of month in a date.

YYYY-MM- DDVariable

Example coming soon.

DAY_OF_MONTH(PROMOTION_TIER_START_DATE)

Month Returns number of month in a date.

YYYY- MM-DDVariable

Example coming soon.

MONTH(PROMOTION_TIER_EXPIRATION_DATE)

Year Returns year in a date.

YYYY-MM-DDVariable

Example coming soon.

YEAR(VOUCHER_START_DATE)


Complex Expression Operators

Here are the discount formula operators you can choose from for creating complex expressions. 

Operand
How does it work?
Use case
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.
Give customer 20% off every time they make a purchase after their 10 th 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. Give customer 20% off every time they make a purchase after their 10 th 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)


Nested Formulas

You can create nested expressions by embedding statements within true and false blocks of logical IF statements. 

How does it work?
Use case
If a condition is true, the logical expression will follow the nested path defined inside the condition. If the condition is false, the logical expression will follow the other path.
Give customer 25% off if the order amount is greater than 200 and the quantity of items in the cart is more than 4; otherwise give customers 15% off. If the customer does not have more than 4 items in the cart, the customer gets 10% off.

IF(ORDER_ITEMS_QUANTITY > 4;IF(ORDER_AMOUNT > 200;25;15);10)

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