{
  "id": "<root>",
  "type": "ROOT",
  "entryPoint": {
    "id": "check-collection",
    "then": {
      "id": "check-qty-6",
      "then": {
        "id": "apply-qty-6",
        "type": "APPLY_DISCOUNT",
        "title": "Buy One Get One Free three times",
        "value": {
          "rest": null,
          "type": "RANKED",
          "ranks": [
            {
              "discount": {
                "type": "PERCENTAGE",
                "percentage": "100"
              }
            },
            {
              "discount": {
                "type": "PERCENTAGE",
                "percentage": "100"
              }
            },
            {
              "discount": {
                "type": "PERCENTAGE",
                "percentage": "100"
              }
            },
            {
              "discount": null
            },
            {
              "discount": null
            },
            {
              "discount": null
            }
          ]
        }
      },
      "type": "CHECK_IF",
      "matchType": "AND",
      "otherwise": {
        "id": "check-qty-5",
        "then": {
          "id": "apply-qty-5",
          "type": "APPLY_DISCOUNT",
          "title": "BOGO twice plus 30% off remaining item",
          "value": {
            "rest": null,
            "type": "RANKED",
            "ranks": [
              {
                "discount": {
                  "type": "PERCENTAGE",
                  "percentage": "100"
                }
              },
              {
                "discount": {
                  "type": "PERCENTAGE",
                  "percentage": "100"
                }
              },
              {
                "discount": {
                  "type": "PERCENTAGE",
                  "percentage": "30"
                }
              },
              {
                "discount": null
              },
              {
                "discount": null
              }
            ]
          }
        },
        "type": "CHECK_IF",
        "matchType": "AND",
        "otherwise": {
          "id": "check-qty-4",
          "then": {
            "id": "apply-qty-4",
            "type": "APPLY_DISCOUNT",
            "title": "Buy One Get One Free twice",
            "value": {
              "rest": null,
              "type": "RANKED",
              "ranks": [
                {
                  "discount": {
                    "type": "PERCENTAGE",
                    "percentage": "100"
                  }
                },
                {
                  "discount": {
                    "type": "PERCENTAGE",
                    "percentage": "100"
                  }
                },
                {
                  "discount": null
                },
                {
                  "discount": null
                }
              ]
            }
          },
          "type": "CHECK_IF",
          "matchType": "AND",
          "otherwise": {
            "id": "check-qty-3",
            "then": {
              "id": "apply-qty-3",
              "type": "APPLY_DISCOUNT",
              "title": "Cheapest free and middle item 30% off",
              "value": {
                "rest": null,
                "type": "RANKED",
                "ranks": [
                  {
                    "discount": {
                      "type": "PERCENTAGE",
                      "percentage": "100"
                    }
                  },
                  {
                    "discount": {
                      "type": "PERCENTAGE",
                      "percentage": "30"
                    }
                  },
                  {
                    "discount": null
                  }
                ]
              }
            },
            "type": "CHECK_IF",
            "matchType": "AND",
            "otherwise": {
              "id": "check-qty-2",
              "then": {
                "id": "apply-qty-2",
                "type": "APPLY_DISCOUNT",
                "title": "Cheaper item free",
                "value": {
                  "rest": null,
                  "type": "RANKED",
                  "ranks": [
                    {
                      "discount": {
                        "type": "PERCENTAGE",
                        "percentage": "100"
                      }
                    },
                    {
                      "discount": null
                    }
                  ]
                }
              },
              "type": "CHECK_IF",
              "matchType": "AND",
              "otherwise": {
                "id": "check-qty-1",
                "then": {
                  "id": "apply-qty-1",
                  "type": "APPLY_DISCOUNT",
                  "title": "30% off one eligible item",
                  "value": {
                    "rest": null,
                    "type": "RANKED",
                    "ranks": [
                      {
                        "discount": {
                          "type": "PERCENTAGE",
                          "percentage": "30"
                        }
                      }
                    ]
                  }
                },
                "type": "CHECK_IF",
                "matchType": "AND",
                "otherwise": null,
                "conditions": [
                  {
                    "type": "PURCHASE_REQUIREMENTS",
                    "minOrMax": "MIN",
                    "requirements": {
                      "quantity": "1",
                      "subtotal": "0",
                      "appliesTo": "ELIGIBLE_LINE_ITEMS",
                      "requirementType": "QUANTITY",
                      "disableCurrencyConversion": false
                    }
                  },
                  {
                    "type": "PURCHASE_REQUIREMENTS",
                    "minOrMax": "MAX",
                    "requirements": {
                      "quantity": "1",
                      "subtotal": "0",
                      "appliesTo": "ELIGIBLE_LINE_ITEMS",
                      "requirementType": "QUANTITY",
                      "disableCurrencyConversion": false
                    }
                  }
                ]
              },
              "conditions": [
                {
                  "type": "PURCHASE_REQUIREMENTS",
                  "minOrMax": "MIN",
                  "requirements": {
                    "quantity": "2",
                    "subtotal": "0",
                    "appliesTo": "ELIGIBLE_LINE_ITEMS",
                    "requirementType": "QUANTITY",
                    "disableCurrencyConversion": false
                  }
                },
                {
                  "type": "PURCHASE_REQUIREMENTS",
                  "minOrMax": "MAX",
                  "requirements": {
                    "quantity": "2",
                    "subtotal": "0",
                    "appliesTo": "ELIGIBLE_LINE_ITEMS",
                    "requirementType": "QUANTITY",
                    "disableCurrencyConversion": false
                  }
                }
              ]
            },
            "conditions": [
              {
                "type": "PURCHASE_REQUIREMENTS",
                "minOrMax": "MIN",
                "requirements": {
                  "quantity": "3",
                  "subtotal": "0",
                  "appliesTo": "ELIGIBLE_LINE_ITEMS",
                  "requirementType": "QUANTITY",
                  "disableCurrencyConversion": false
                }
              },
              {
                "type": "PURCHASE_REQUIREMENTS",
                "minOrMax": "MAX",
                "requirements": {
                  "quantity": "3",
                  "subtotal": "0",
                  "appliesTo": "ELIGIBLE_LINE_ITEMS",
                  "requirementType": "QUANTITY",
                  "disableCurrencyConversion": false
                }
              }
            ]
          },
          "conditions": [
            {
              "type": "PURCHASE_REQUIREMENTS",
              "minOrMax": "MIN",
              "requirements": {
                "quantity": "4",
                "subtotal": "0",
                "appliesTo": "ELIGIBLE_LINE_ITEMS",
                "requirementType": "QUANTITY",
                "disableCurrencyConversion": false
              }
            },
            {
              "type": "PURCHASE_REQUIREMENTS",
              "minOrMax": "MAX",
              "requirements": {
                "quantity": "4",
                "subtotal": "0",
                "appliesTo": "ELIGIBLE_LINE_ITEMS",
                "requirementType": "QUANTITY",
                "disableCurrencyConversion": false
              }
            }
          ]
        },
        "conditions": [
          {
            "type": "PURCHASE_REQUIREMENTS",
            "minOrMax": "MIN",
            "requirements": {
              "quantity": "5",
              "subtotal": "0",
              "appliesTo": "ELIGIBLE_LINE_ITEMS",
              "requirementType": "QUANTITY",
              "disableCurrencyConversion": false
            }
          },
          {
            "type": "PURCHASE_REQUIREMENTS",
            "minOrMax": "MAX",
            "requirements": {
              "quantity": "5",
              "subtotal": "0",
              "appliesTo": "ELIGIBLE_LINE_ITEMS",
              "requirementType": "QUANTITY",
              "disableCurrencyConversion": false
            }
          }
        ]
      },
      "conditions": [
        {
          "type": "PURCHASE_REQUIREMENTS",
          "minOrMax": "MIN",
          "requirements": {
            "quantity": "6",
            "subtotal": "0",
            "appliesTo": "ELIGIBLE_LINE_ITEMS",
            "requirementType": "QUANTITY",
            "disableCurrencyConversion": false
          }
        },
        {
          "type": "PURCHASE_REQUIREMENTS",
          "minOrMax": "MAX",
          "requirements": {
            "quantity": "6",
            "subtotal": "0",
            "appliesTo": "ELIGIBLE_LINE_ITEMS",
            "requirementType": "QUANTITY",
            "disableCurrencyConversion": false
          }
        }
      ]
    },
    "type": "CHECK_IF",
    "matchType": "AND",
    "otherwise": null,
    "conditions": [
      {
        "type": "PRODUCT_ELIGIBILITY",
        "eligibility": {
          "type": "SPECIFIC_COLLECTIONS",
          "asListOfIds": "eligible-collection",
          "selectedCollections": []
        },
        "includeOrExclude": "INCLUDE"
      }
    ]
  }
}
