Code Samples for Multiple Rule Promotions
This page is for Developer.
Tiered $ off order based on order value
Request
Response
Example request
{"name": "Tiered $ off order based on order value","redemption_type": "AUTOMATIC","rules": [{"action": {"cart_value": {"discount": {"fixed_amount": "45"}}},"apply_once": true,"stop": true,"currency_code": "AUD","condition": {"cart": {"minimum_spend": "175"}}},{"action": {"cart_value": {"discount": {"fixed_amount": "30"}}},"apply_once": true,"stop": true,"condition": {"cart": {"minimum_spend": "150"}}},{"action": {"cart_value": {"discount": {"fixed_amount": "15"}}},"apply_once": true,"stop": true,"condition": {"cart": {"minimum_spend": "100"}}}],"notifications": [{"type": "UPSELL","content": "<div> </div>","locations": ["CART_PAGE"]},{"type": "ELIGIBLE","content": "<div> </div>","locations": ["CART_PAGE"]},{"type": "APPLIED","content": "<div> </div>","locations": ["CART_PAGE"]}],"stop": false,"start_date": "2019-02-01T05:00:00+00:00","status": "ENABLED"}
Apply a tiered discount to X products based on the quantity of items ordered within X
Request
Response
Example request
{"name": "Apply a tiered discount to applicable products based on the quantity of items ordered within X ","redemption_type": "AUTOMATIC","rules": [{"action": {"cart_items": {"discount": {"fixed_amount": "20"},"strategy": "LEAST_EXPENSIVE","as_total": true,"include_items_considered_by_condition": true,"items": {"categories": [24]}}},"apply_once": true,"stop": true,"condition": {"cart": {"items": {"categories": [35]},"minimum_quantity": 4}}},{"action": {"cart_items": {"discount": {"fixed_amount": "15"},"strategy": "LEAST_EXPENSIVE","as_total": true,"include_items_considered_by_condition": true,"items": {"categories": [25]}}},"apply_once": true,"stop": true,"condition": {"cart": {"items": {"categories": [25]},"minimum_quantity": 3}}},{"action": {"cart_items": {"discount": {"fixed_amount": "10"},"strategy": "LEAST_EXPENSIVE","as_total": true,"include_items_considered_by_condition": true,"items": {"categories": [30]}}},"apply_once": true,"stop": true,"condition": {"cart": {"items": {"categories": [36]},"minimum_quantity": 2}}}],"notifications": [{"type": "UPSELL","content": "<div> </div>","locations": ["CART_PAGE"]},{"type": "ELIGIBLE","content": "<div> </div>","locations": ["CART_PAGE"]},{"type": "APPLIED","content": "<div> </div>","locations": ["CART_PAGE"]}],"stop": true,"start_date": "2019-02-01T05:00:00+00:00","status": "ENABLED"}
Up to 50% off storewide (50% off category X items and 40% off everything else)
Request
Response
Example request
{"name": "Up to 50% off storewide (50% off category X items and 40% off everything else)","redemption_type": "AUTOMATIC","rules": [{"action": {"cart_items": {"discount": {"percentage_amount": 50},"items": {"categories": [36]}}},"apply_once": true},{"action": {"cart_items": {"discount": {"percentage_amount": 40},"items": {"not": {"categories": [24]}}}},"apply_once": true}]}
Buy X products, get free shipping, and 10% off order
Request
Response
Example request
{"name": "Buy two of product X, get free shipping to all zones, and 10% off order","redemption_type": "AUTOMATIC","rules": [{"condition": {"cart": {"items": {"products": [118]},"minimum_quantity": 2}},"action": {"shipping": {"free_shipping": true,"zone_ids": "*"}}},{"condition": {"cart": {"items": {"products": [130]},"minimum_quantity": 2}},"action": {"cart_value": {"discount": {"percentage_amount": 10}}}}]}