I get this working using the
DiscountApplicationStrategy.All
Here is my function result output:
{
"discounts": [
{
"targets": [
{
"productVariant": {
"id": "gid://shopify/ProductVariant/40927689801903"
}
}
],
"value": {
"percentage": {
"value": 15
}
},
"message": "15% off for 3+"
},
{
"targets": [
{
"productVariant": {
"id": "gid://shopify/ProductVariant/40927683149999"
}
}
],
"value": {
"percentage": {
"value": 10
}
},
"message": "10% off for 2"
},
{
"targets": [
{
"productVariant": {
"id": "gid://shopify/ProductVariant/40927683084463"
}
}
],
"value": {
"percentage": {
"value": 10
}
},
"message": "10% off for 2"
},
{
"targets": [
{
"productVariant": {
"id": "gid://shopify/ProductVariant/40927689703599"
}
}
],
"value": {
"percentage": {
"value": 15
}
},
"message": "15% off for 3+"
}
],
"discountApplicationStrategy": "ALL"
}
And here is the array with the discounts that I am sending to the discount field in the return of the run function,
[
{
"targets": [
{
"productVariant": {
"id": "gid://shopify/ProductVariant/40927689801903"
}
}
],
"value": {
"percentage": {
"value": 15
}
},
"message": "15% off for 3+"
},
{
"targets": [
{
"productVariant": {
"id": "gid://shopify/ProductVariant/40927683149999"
}
}
],
"value": {
"percentage": {
"value": 10
}
},
"message": "10% off for 2"
},
{
"targets": [
{
"productVariant": {
"id": "gid://shopify/ProductVariant/40927683084463"
}
}
],
"value": {
"percentage": {
"value": 10
}
},
"message": "10% off for 2"
},
{
"targets": [
{
"productVariant": {
"id": "gid://shopify/ProductVariant/40927689703599"
}
}
],
"value": {
"percentage": {
"value": 15
}
},
"message": "15% off for 3+"
}
]
This is for a tiered quantity discount offer.
- Group By ProductID and Sum Quantities
- Apply discount to variants based on the grouped quantities by product.