Need to create rules based on bundles?
Learn more
LogoLogo
APIsChangelog
  • Getting started
  • Rules
  • Conditions
    • Scope
    • Aggregations
    • Nested
    • Dynamic values
  • Actions
    • Types
      • Percentage
      • Fixed amount
      • Fixed price
      • Buy X pay Y
      • Every X discount Y
    • Bundle
      • Balanced
      • Every
    • Aggregation
    • Limit
  • Matchers
  • Operators
  • Check and validation
  • Core API integration
    • Order rules
    • Price rules
    • Virtual relationships
  • Resources
    • Promotions
    • Price lists
  • Use cases
    • Promotions
      • Discount line items based on item's price
      • Get a discount when paying by credit card
      • Discount an order based on promo item and total number of items
      • Offer a specific shipping method for free in a specific country
      • Discount items with large stock availability
      • Discount all the SKU in an order based on the shipping country
      • Discount all the SKU in an order based on the customer email domain
    • Price lists
      • Discount all prices greater than or equal to a specific value
      • Discount specific SKUs for new clients
      • Change strike-through price based on customer email domain
On this page
  • Rules breakdown
  • Resource payload analysis
  • Result check
  • Conclusion
  1. Use cases
  2. Price lists

Change strike-through price based on customer email domain

Rule breakdown, resource payload analysis, and outcomes explanation

This rule discounts the compare-at amount of a price for logged customers whose email address matches a specific domain. The customer email is checked and a percentage discount is applied to the related price. Applying this rule to a price list will result in updating the compare-at amount of all its prices for a subset of logged customers.

The example below is based on the following reference JSONs. Once the rules are evaluated against the resource payload, the outcomes show if and how the conditions are matched and the related actions applied.

{
  "rules": [
    {
      "name": "Updates compares at based on customer email domain",
      "conditions": [
        {
          "field": "price.jwt_customer.email",
          "matcher": "matches",
          "value": ".*@mybrand.com"
        }
      ],
      "actions": [
        {
          "type": "percentage",
          "selector": "price",
          "apply_on": "compare_at_amount_cents",
          "value": 0.2
        }
      ]
    }
  ]
} 
{
  "price": {
    "id": "lpeNYUvMTE",
    "jwt_customer": {
      "email": "john.doe@mybrand.com",
      "id": "klzEhmRAMM"
    }
  }
}
[
  {
    "id": "bc0c0d09-b216-4cfd-9b9d-dc37301aed48",
    "name": "Updates compares at based on customer email domain",
    "priority": 0,
    "match": true,
    "conditions_logic": "and",
    "conditions": [
      {
        "field": "price.jwt_customer.email",
        "matcher": "matches",
        "value": ".*@mybrand.com",
        "group": "d3b92cd3-bff2-46b4-bd89-7c4b8dac86c2",
        "match": true,
        "scope": "any",
        "matches": [
          {
            "price": "lpeNYUvMTE",
            "jwt_customer": "klzEhmRAMM",
            "group": "d3b92cd3-bff2-46b4-bd89-7c4b8dac86c2"
          }
        ]
      }
    ],
    "actions": [
      {
        "resources": [
          {
            "resource_type": "prices",
            "id": "lpeNYUvMTE",
            "group": "d3b92cd3-bff2-46b4-bd89-7c4b8dac86c2",
            "quantity": null,
            "value": 0.2,
            "action_type": "percentage",
            "apply_on": "compare_at_amount_cents"
          }
        ]
      }
    ]
  }
]

Rules breakdown

The desired results can be achieved with a single rule.

Conditions

The only condition in the rule checks if the customer email belongs to the domain .*@mybrand.com.

Actions

The only action in the rule applies a 20% discount to the compare_at_amount_cents value of the prices that match the condition.

Resource payload analysis

The provided payload contains a price associated with a logged customer whose email is john.doe@mybrand.com, thus qualifying for the discount.

Result check

The outcomes reflect the evaluation of the rules against the resource payload. Since the price satisfies the condition, the rule matches successfully (match is true). The price and the logged customer IDs are listed within the matches array. The action is applied to the price's compare_at_amount_cents attribute with a decimal value of 0.2 corresponding to the specified percentage discount.

Conclusion

The rule matches the provided price payload. Consequently, a 20% discount is applied to the strike-through price due to its association with a customer's email that matches the specified domain.

PreviousDiscount specific SKUs for new clients

Last updated 2 months ago