Discount all prices greater than or equal to a specific value

Rule breakdown, resource payload analysis, and outcomes explanation

This rule discounts a price based on its amount. The price amount in cents is checked and a percentage discount is applied if it's greater than or equal to a specific value. Applying this rule to a price list will result in discounting all its prices whose amounts are greater than or equal to the provided value.

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": "Price with amount_cents greather than equal 200",
      "conditions": [
        {
          "field": "price.amount_cents",
          "matcher": "gteq",
          "value": 200
        }
      ],
      "actions": [
        {
          "type": "percentage",
          "selector": "price",
          "value": 0.2
        }
      ]
    }
  ]
} 

Rules breakdown

The desired results can be achieved with a single rule.

Conditions

The only condition in the rule checks if the price amount is greater than or equal to 200 cents.

Actions

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

Resource payload analysis

The provided payload contains a price whose amount is 12300 cents, thus qualifying for the discount.

Outcomes 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 ID is listed within the matches array. The action is applied to the price 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 price due to its amount being over the specified threshold.

Last updated