Builder API - Loyalty Discount Types

In order to create discounts for a loyalty scheme, a scheme needs to have been setup. See Loyalty Schemes Management for details.

See Example Loyalty Scheme for an end-to-end example of setting up a loyalty scheme.

Accrue Loyalty Points

Points can be accrued using a fixed number of points or a ratio of currency to points.

An example of an action to accrue a fixed number of points (10 points) is below.

{
  "name": "Accrue Points - Fixed Example",
  "conditions": [],
  "actions": [
    {
      "type": "AccrueLoyaltyPoints",
      "loyaltySchemeId": "e1ce8ffb-38ef-4b6b-9fae-6ab8c8d7d6fa",
      "calculatorType": "Fixed",
      "values": [
        {
          "condition": null,
          "value": 10
        }
      ]
    }
  ]
}

An example of an action to accrue based on a ratio is below. This uses the Evaluator option which will use the overall current total (basket and any costs). You can also use Basket to just use the current basket total.

{
  "name": "Accrue Points - Ratio Example",
  "conditions": [],
  "actions": [
    {
      "type": "AccrueLoyaltyPoints",
      "loyaltySchemeId": "e1ce8ffb-38ef-4b6b-9fae-6ab8c8d7d6fa",
      "calculatorType": "Ratio",
      "ratioTarget": "Evaluator",
      "values": [
        {
          "condition": null,
          "value": [
            {
              "currencyCode": "GBP",
              "currencyToPointsRatio": 0.01
            },
            {
              "currencyCode": "USD",
              "currencyToPointsRatio": 0.02
            }
          ]
        }
      ]
    }
  ]
}

To set a start date for points you can either use a relative date (relative to when the points are accrued) or an absolute date.

All absolute dates are in the time zone of the project.

Below is an example using a relative start date for points.

{
  "name": "Accrue Points - Relative Start Example",
  "conditions": [],
  "actions": [
    {
      "type": "AccrueLoyaltyPoints",
      "loyaltySchemeId": "e1ce8ffb-38ef-4b6b-9fae-6ab8c8d7d6fa",
      "calculatorType": "Fixed",
      "relativePointsStart": {
        "unit": "Days",
        "value": 1
      },
      "values": [
        {
          "condition": null,
          "value": 10
        }
      ]
    }
  ]
}

Below is an example of an absolute start date for points.

{
  "name": "Accrue Points - Absolute Start Example",
  "conditions": [],
  "actions": [
    {
      "type": "AccrueLoyaltyPoints",
      "loyaltySchemeId": "e1ce8ffb-38ef-4b6b-9fae-6ab8c8d7d6fa",
      "calculatorType": "Fixed",
      "absolutePointsStart": "2023-11-01T00:00:00",
      "values": [
        {
          "condition": null,
          "value": 10
        }
      ]
    }
  ]
}

In a similar way, expiry of points can specified using absolutePointsExpiry or relativePointsExpiry.

Redeeming Points

There are two types of actions that can be used to spend points:

  • RedeemLoyaltyPoints - allows redeeming a fixed number of points.
  • PayWithLoyaltyPoints - this will take an amount off and redeem the points.

RedeemLoyaltyPoints

{
  "name": "Redeem Points Example",
  "conditions": [],
  "actions": [
    {
      "type": "RedeemLoyaltyPoints",
      "loyaltySchemeId": "e1ce8ffb-38ef-4b6b-9fae-6ab8c8d7d6fa",
      "values": [
        {
          "condition": null,
          "value": 10
        }
      ]
    }
  ]
}

PayWithLoyaltyPoints

{
  "name": "Pay with Points Example",
  "conditions": [],
  "actions": [
    {
      "type": "PayWithLoyaltyPoints",
      "loyaltySchemeId": "e1ce8ffb-38ef-4b6b-9fae-6ab8c8d7d6fa",
      "ratioTarget": "Evaluator",
      "values": [
        {
          "condition": null,
          "value": [
            {
              "currencyCode": "GBP",
              "pointsToCurrencyRatio": 0.01
            },
            {
              "currencyCode": "USD",
              "pointsToCurrencyRatio": 0.02
            }
          ]
        }
      ]
    }
  ]
}

Loyalty Eligibility Expressions

When you create a loyalty scheme a number of properties are created that can be used in eligibility expressions. These are detailed below

A top level property called Loyalty is created unless it already exists.

An object property with a dynamic name of Scheme_[loyaltySchemeId] is created (e.g. Scheme_e1ce8ffb-38ef-4b6b-9fae-6ab8c8d7d6fa) as a child of the Loyalty property. This property has a number of child properties:

  • ActiveInScheme - true if there is a matching entry in the scheme
  • Balance - the balance of the entry
  • Tiers - the tiers from the loyalty scheme that the entry matches (if any)

Below are discount examples of using these properties.

Accrue Points if Active In Scheme

The discount below will only accrue points if the request matches an existing entry in the scheme.

{
  "name": "Accrue Points if Active in Scheme Example",
  "conditions": [
    {
      "eligibilityExpression": {
        "type": "Group",
        "conjunction": "And",
        "clauses": [
          {
            "type": "Property",
            "property": "Loyalty.Scheme_e1ce8ffb-38ef-4b6b-9fae-6ab8c8d7d6fa.ActiveInScheme",
            "operator": "equals",
            "value": true
          }
        ]
      }
    }
  ],
  "actions": [
    {
      "type": "AccrueLoyaltyPoints",
      "loyaltySchemeId": "e1ce8ffb-38ef-4b6b-9fae-6ab8c8d7d6fa",
      "calculatorType": "Fixed",
      "values": [
        {
          "condition": null,
          "value": 10
        }
      ]
    }
  ]
}

Amount off if Minimum Loyalty Points

The discount below gives 5% off for customers with more than 10000 points.

{
  "name": "5% off for customers with more than 10000 points example",
  "conditions": [
    {
      "eligibilityExpression": {
        "type": "Group",
        "conjunction": "And",
        "clauses": [
          {
            "type": "Property",
            "property": "Loyalty.Scheme_e1ce8ffb-38ef-4b6b-9fae-6ab8c8d7d6fa.Balance",
            "operator": "greaterthan",
            "value": 10000
          }
        ]
      }
    }
  ],
  "actions": [
    {
      "type": "AmountOffBasket",
      "amountOffType": "PercentOff",
      "values": [
        {
          "condition": null,
          "value": 5
        }
      ]
    }
  ]
}

Loyalty Scheme Tiers

The example discount below gives 10% off if the entry is in the Gold tier, otherwise it gives 5%. This example assumes the loyalty scheme has a tier with the name Gold setup on it. The condition also checks the entry already exists in the loyalty scheme.

{
  "name": "Percent off with loyalty tier example",
  "conditions": [
    {
      "eligibilityExpression": {
        "type": "Group",
        "conjunction": "And",
        "clauses": [
          {
            "type": "Property",
            "property": "Loyalty.Scheme_e1ce8ffb-38ef-4b6b-9fae-6ab8c8d7d6fa.ActiveInScheme",
            "operator": "equals",
            "value": true
          }
        ]
      }
    }
  ],
  "actions": [
    {
      "type": "AmountOffBasket",
      "amountOffType": "PercentOff",
      "values": [
        {
          "condition": {
            "type": "Group",
            "conjunction": "And",
            "clauses": [
              {
                "type": "Property",
                "property": "Loyalty.Scheme_e1ce8ffb-38ef-4b6b-9fae-6ab8c8d7d6fa.Tiers",
                "operator": "contains",
                "value": "Gold"
              }
            ]
          },
          "value": 10
        },
        {
          "condition": null,
          "value": 5
        }
      ]
    }
  ]
}