Configuring discount rules

Discount rules are user-friendly representations of macro conditions used to limit catalog discounts, order discountsfree shipping offers, and gift cards. If the system evaluates the condition as true, the respective discount or offer is valid and the system applies it (unless configured otherwise). This page describes how to extend the default conditions. When writing rule conditions, you can either use the available macro syntax or include custom macro methods.

There are two types of the discount rules:

  • Catalog rules – used by catalog discounts
  • Order rules – used by order discounts, free shipping offers and gift cards

Catalog and order rule differences

The main difference between the rule types is the data available for the conditions.

  • Catalog discounts apply to products. The data available for catalog rules includes product attributes, i.e. the product’s SKUInfo object and its properties, available under the SKU macro property. For example, SKU.SKUOrderSKU.SKUPriceSKU.SKUPublicStatus, etc.
  • Order discounts, free shipping offers and gift cards apply to entire orders. The data available for order rules includes values related to the shopping cart or order calculation, such as Currency, Customer, PaymentOption, ShippingOption, GrandTotal, etc.

Using context objects not related to the product or shopping cart calculation data

We strongly recommend NOT using time-related objects such as CurrentUser or CurrentPath in your custom discount rules.

These objects may no longer be relevant in the session context at the time of evaluation, causing unexpected application of discounts or offers that use the rule in their condition.

Currency of monetary values in order rules

For Order rules, all monetary macro properties (GrandTotal, OrderDiscount, Tax, etc.) have values in the currency that the customer selected for the evaluated shopping cart or order.

If you have a store with multiple currencies and are creating an order rule that evaluates a monetary value, you need to adjust the condition code according to the currency (for example using the Currency.CurrencyCode property).

Adding discount rules

You can add new discount rules using macro rules directly from the Xperience administration interface:

  1. Open the Store configurationapplication if you want to create a discount rule for the current site. Open the Multistore configuration application if you run multiple sites on the same Xperience instance and want to add the rule for all sites.

    If you are not sure what to choose, see Choosing site or global e-commerce configuration. If you are not sure about specifics of configuring in these applications, see Configuring e-commerce settings for a specific site or globally.

  2. Select the Discount rules -> Catalog rules tab to manage catalog discount rules. Select the Discount rules -> Order rules tab to manage order discount rules.

  3. Click New catalog rulewhen on the Catalog rulestab. Click New order rule when on the Order rules tab.

  4. Fill in the discount rule’s properties:

    General

    Display name

    The name of the discount rule displayed in the administration interface. For example, when editing a discount.

    Name

    The unique identifier of the discount rule object used in the code.

    Unless there is a reason to set a particular value, you can leave the default (automatic) option, and the system generates an appropriate code name automatically.

    Description

    To make the discount rule easier to use and maintain, you can add an explanation about the scenarios for which the rule is intended, etc. The description does not have any functionality; it is just for your better orientation.

    Enabled

    Indicates if the discount rule is available to use when editing a discount. If the check box is cleared, the system does not display the rule.

    Rule data

    User text

    The text displayed in the discount rule designer window.

    To add parameters to the text, type their name of a specific parameter enclosed in curly brackets. For example: {days}

    Condition

    The macro condition represented by the rule. Define the condition through standard macro code. The field provides autocomplete support.

    Available data:

    • Catalog rules – access the properties of the evaluated SKU (product) by typing SKU, a period character, and then pressing CTRL+SPACE. Select properties from the displayed autocomplete menu.
    • Order rules – access the data of the evaluated shopping cart or order by pressing CTRL+SPACE. The displayed autocomplete menu offers the most common properties, such as Currency, Customer, PaymentOption, ShippingOption, GrandTotal, TotalItemsWeight, etc. You can access the full shopping cart calculation data via the Data property, which is primarily intended for evaluating the shopping cart content using the Data.ContainsProducts method or for use within custom macro methods.Available data for catalog rules

    Required data

    Leave this property empty.

    Requires context

    Leave this property empty.

    More detailed information

    To learn more about entering the rule data, see Creating macro rules.

  5. If your discount rule contains any parameters, switch to the Parameters tab.

    1. Configure the parameters as any other field in Field editor.
    2. Click Save.

The discount rule is now configured and saved. Store managers can use the rule for their discounts and special offers.

Discount rules using a custom macro method (more advanced)

For more advanced rules and scenarios that cannot be achieved using the default Xperience macros, you can develop a custom macro method and then call that method in your discount rules.

To learn how to create a discount rule that uses a custom macro method, see: Adding a discount rule with a custom method