Multiple discounts in one operation

Hey friends!

Pretty new to Rust and this is my first time building a discount app— I’m working to replace a Script that our company has relied on for a particular promotion.

It breaks down to this:

Buy X and Y, get 20% off of X and Y plus add on Z for free (100% off)

I’ve managed to set up the run and apply the 20% off to the X and Y cart lines, but the add on candidate is not being discounted. Is this a limitation, or am I just doing it wrong?

If this is a limitation, are there any workarounds to this, other than setting up two discounts?

Here’s the operation output from most recent run log:

"operations": [
  {
    "productDiscountsAdd": {
      "candidates": [
        {
          "message": "Core bundle",
          "targets": [
            { "cartLine": { "id": "gid://shopify/CartLine/0", "quantity": 1 } },
            { "cartLine": { "id": "gid://shopify/CartLine/1", "quantity": 1 } }
          ],
          "value": { "percentage": { "value": "20.0" } }
        },
        {
          "message": "Free add on",
          "targets": [
            { "cartLine": { "id": "gid://shopify/CartLine/2", "quantity": 1 } }
          ],
          "value": { "percentage": { "value": "100.0" } }
        }
      ],
      "selectionStrategy": "FIRST"
    }
  }
]

I’m not getting any errors or anything, but it’s just silently failing.

Thanks for any information in advance!

—Kyle

Figured it out :man_facepalming: selectionStrategy should be "ALL"

I thought selectionStrategy only applied to multiple discounts on the same cart lines, not which candidates to apply.