Offer a specific shipping method for free in a specific country

Rule breakdown, resource payload analysis, and outcomes explanation

This rule discounts a shipping method for all the orders in a given country. The country code of the order is checked and, if it matches the desired country, a 100% percentage discount is applied to the shipment line items (if any) whose shipment has a shipping method that matches the provided ID.

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": "Free express shipment for US orders",
      "conditions": [
        {
          "field": "order.country_code",
          "matcher": "eq",
          "value": "US"
        }
      ],
      "actions": [
        {
          "type": "percentage",
          "selector": "order.line_items.shipment.shipping_method.id",
          "value": 1.0,
          "identifier": "bEegQFyxNw"
        }
      ]
    }
  ]
} 

Rules breakdown

The desired results can be achieved with a single rule.

Conditions

The only condition in the rule checks if the order's country_code is equal to US. This means the rule will only apply if the order is placed from the United States.

Actions

The only action in the rule applies a 100% percentage discount to the order's shipment line items that are associated with the shipping method that should be free of charge. The shipment line item eligible for the discount is detected via a selector on the ID of the shipping method (bEegQFyxNw).

Resource payload analysis

The provided payload contains an order placed from the US that has 4 line items: 2 products whose delivery is split into 2 shipments. For one of the shipments (eNdLCKWxly, associated with the line item vRrYtpaaKv) the shipping method that should be discounted has been selected.

Outcomes check

The outcomes reflect the evaluation of the rules against the resource payload. Since the order is placed from the US, the rule matches successfully (match is true) and the order ID is listed in the matches array. The action is applied to the identified resource (i.e. the shipping method with ID bEegQFyxNw) with the decimal value of 1.0 corresponding to a full percentage discount.

Conclusion

The rule matches the provided payload. Consequently, the shipment identified as eligible for the discount will have its shipping cost zeroed.

Last updated