Code Samples for Promotions that Use Logical Operators

Buy two of product X or buy two of product Y (OR operator)

The following promotion uses the logical OR operator at item matcher level. Each of the following combinations satisfies the condition:

  • 1 product X + 1 product Y
  • 2 product X
  • 2 product Y
Example request
1{
2 "name": "Buy two of product X or buy two of product Y",
3 "redemption_type": "AUTOMATIC",
4 "rules": [
5 {
6 "condition": {
7 "cart": {
8 "items": {
9 "or": [
10 {
11 "products": [
12 118
13 ]
14 },
15 {
16 "variants": [
17 134
18 ]
19 }
20 ]
21 },
22 "minimum_quantity": 2
23 }
24 },
25 "action": {
26 "gift_item": {
27 "product_id": 130,
28 "quantity": 1
29 }
30 }
31 }
32 ],
33 "notifications": [
34 {
35 "type": "UPSELL",
36 "content": "<div>&nbsp;</div>",
37 "locations": [
38 "CART_PAGE"
39 ]
40 },
41 {
42 "type": "ELIGIBLE",
43 "content": "<div>&nbsp;</div>",
44 "locations": [
45 "CART_PAGE"
46 ]
47 },
48 {
49 "type": "APPLIED",
50 "content": "<div>&nbsp;</div>",
51 "locations": [
52 "CART_PAGE"
53 ]
54 }
55 ],
56 "stop": false,
57 "start_date": "2019-02-01T05:00:00+00:00",
58 "status": "ENABLED"
59}

Get percentage off X category, excluding an item (AND, NOT operators)

Example request
1{
2 "name": "Get 20% off all kitchen items, excluding Able Brewing System",
3 "redemption_type": "AUTOMATIC",
4 "rules": [
5 {
6 "action": {
7 "cart_items": {
8 "items": {
9 "and": [
10 {
11 "categories": [
12 25
13 ]
14 },
15 {
16 "not": {
17 "products": [
18 129
19 ]
20 }
21 }
22 ]
23 },
24 "discount": {
25 "percentage_amount": "20"
26 }
27 }
28 },
29 "apply_once": true
30 }
31 ]
32}

Get X% off all brand X, except X products in brand Y (OR, AND, NOT operators)

Example request
1{
2 "name": "Get 20% off all coffee makers except for those using new arrivals coffee filters",
3 "redemption_type": "AUTOMATIC",
4 "rules": [
5 {
6 "action": {
7 "cart_items": {
8 "items": {
9 "or": [
10 {
11 "and": [
12 {
13 "brands": [
14 37
15 ]
16 },
17 {
18 "categories": [
19 25
20 ]
21 }
22 ]
23 },
24 {
25 "and": [
26 {
27 "brands": [
28 38
29 ]
30 },
31 {
32 "categories": [
33 35
34 ]
35 },
36 {
37 "not": {
38 "categories": [
39 24
40 ]
41 }
42 }
43 ]
44 }
45 ]
46 },
47 "discount": {
48 "percentage_amount": "20"
49 }
50 }
51 },
52 "apply_once": true,
53 "currency_code": "AUD"
54 }
55 ]
56}

X% off storewide except product Y or product Z or any items in category C

Example request
1{
2 "name": "10% off storewide except 'Able Brewing System' or 'Chemex Coffeemaker' or any garden products",
3 "redemption_type": "AUTOMATIC",
4 "rules": [
5 {
6 "action": {
7 "cart_items": {
8 "discount": {
9 "percentage_amount": 10
10 },
11 "items": {
12 "and": [
13 {
14 "not": {
15 "products": [
16 129,
17 130 ]
18 }
19 },
20 {
21 "not": {
22 "categories": [
23 24
24 ]
25 }
26 }
27 ]
28 }
29 }
30 },
31 "apply_once": true
32 }
33 ]
34}