[Bug] discountApplicationStrategy with `All` Type not working when using with multiple variants

[Bug] discountApplicationStrategy with `All` Type not working when using with multiple variants

JackL
Shopify Partner
14 0 11

We have a app that with a function that using discountApplicationStrategy with `All` to have multiple multiple discounts applied to same product variant

the following output is for when same product and only 1 variant:

 

{
  "discountApplicationStrategy": "ALL",
  "discounts": [
    {
      "value": {
        "percentage": {
          "value": 20
        }
      },
      "targets": [
        {
          "productVariant": {
            "id": "gid://shopify/ProductVariant/46960668311869",
            "quantity": 5
          }
        }
      ],
      "message": "Volume discount"
    },
    {
      "value": {
        "percentage": {
          "value": 10
        }
      },
      "targets": [
        {
          "productVariant": {
            "id": "gid://shopify/ProductVariant/46960668311869",
            "quantity": 3
          }
        }
      ],
      "message": "Volume discount"
    }
  ]
}

This do working as expected, the two discounts is applied correctly, the following is the result:

 

JackL_0-1714702883122.png

 

BUT, when it involved with 2 variants from the same product, the second's discount is not applied correctly

the following is the output and result:

{
  "discountApplicationStrategy": "ALL",
  "discounts": [
    {
      "value": {
        "percentage": {
          "value": 20
        }
      },
      "targets": [
        {
          "productVariant": {
            "id": "gid://shopify/ProductVariant/46960668311869",
            "quantity": 3
          }
        },
        {
          "productVariant": {
            "id": "gid://shopify/ProductVariant/46960668377405",
            "quantity": 2
          }
        }
      ],
      "message": "Volume discount"
    },
    {
      "value": {
        "percentage": {
          "value": 10
        }
      },
      "targets": [
        {
          "productVariant": {
            "id": "gid://shopify/ProductVariant/46960668311869",
            "quantity": 3
          }
        }
      ],
      "message": "Volume discount"
    }
  ]
}

JackL_1-1714702973799.png

We believed this is a bug as it is working when only single variant but not when multiple

Please let us know or if the Shopify's function expecting any format of output to handle this situation

Thanks in advance!

Replies 2 (2)

originmaster
Shopify Partner
45 2 19

I am experiencing the same a similar issue. When multiple targets are returned that have the same variant ID and are discounted at different rates no discount is being applied.

This function output results in no discount:

{
  "discounts": [
    {
      "targets": [
        {
          "productVariant": {
            "id": "gid://shopify/ProductVariant/45808962994471",
            "quantity": 2
          }
        }
      ],
      "value": {
        "percentage": {
          "value": 10
        }
      },
      "message": "Bundle Discount"
    },
    {
      "targets": [
        {
          "productVariant": {
            "id": "gid://shopify/ProductVariant/45808962994471"
          }
        }
      ],
      "value": {
        "percentage": {
          "value": 20
        }
      },
      "message": "Vendor Discount"
    }
  ],
  "discountApplicationStrategy": "ALL"
}

 

originmaster
Shopify Partner
45 2 19

The issue I'm experiencing seems different to OP. I was able to get my discount working by adding a "quantity" to the second target. This appears to be a bug as "quantity" property is not a required field and my understanding is that the discount should apply without it. This used to work but seems to be a recently introduced bug.