Discounting a session based on purchase location
Let's create a customer session custom attribute referring to the customer's shipping city and use it in a promotion rule to discount the session total.
Storing the shipping city
Let's start by storing the customer's shipping city so we can use it in the Rule Builder. To do this, we create a custom attribute.
- Associated entity:
- Attribute type:
- API name:
- Rule Builder name:
- Rule Builder description:
Customer session shipping city
- Picklist values:
- Available in our Application
Setting the value of the attribute
The attribute is ready to be used by the integration layer. Since we have created a customer session attribute, its value is set programmatically using the Update customer session endpoint.
For example, we can set
Berlin with the following payload:
Issuing a discount on the session total
Let's build the rule for customers who choose Berlin as their shipping city to receive a
discount. We can name it
Discount on session total when shipping to Berlin, and it has 1
condition and 1 effect.
Validate attribute value:
- Attribute is Shipping city (current session).
- Is equal to
Discount session total: Name is
Berlin 10% off and Discount value is