Currently, when targeting, or setting a condition o an orderSubtotal, you can pass an array of fully formed ‘gids’ to exclude:
{"output": {
"discountApplicationStrategy": "MAXIMUM",
"discounts": [
{
"conditions": [
{
"orderMinimumSubtotal": {
"excludedVariantIds": [
"gid://shopify/ProductVariant/51476482818382",
"gid://shopify/ProductVariant/51476482949454",
"gid://shopify/ProductVariant/51476483178830",
"gid://shopify/ProductVariant/51476483277134"
],
"minimumAmount": "1000.0",
"targetType": "ORDER_SUBTOTAL"
}
}
],
"message": "TIER 1",
"targets": [
{
"orderSubtotal": {
"excludedVariantIds": [
"gid://shopify/ProductVariant/51476482818382",
"gid://shopify/ProductVariant/51476482949454",
"gid://shopify/ProductVariant/51476483178830",
"gid://shopify/ProductVariant/51476483277134"
]
}
}
],
"value": {
"percentage": {
"value": "10.0"
}
}
},
{
"conditions": [
{
"orderMinimumSubtotal": {
"excludedVariantIds": [
"gid://shopify/ProductVariant/51476482818382",
"gid://shopify/ProductVariant/51476482949454",
"gid://shopify/ProductVariant/51476483178830",
"gid://shopify/ProductVariant/51476483277134"
],
"minimumAmount": "2000.0",
"targetType": "ORDER_SUBTOTAL"
}
}
],
"message": "TIER 2",
"targets": [
{
"orderSubtotal": {
"excludedVariantIds": [
"gid://shopify/ProductVariant/51476482818382",
"gid://shopify/ProductVariant/51476482949454",
"gid://shopify/ProductVariant/51476483178830",
"gid://shopify/ProductVariant/51476483277134"
]
}
}
],
"value": {
"percentage": {
"value": "20.0"
}
}
}
]
},
}
Notice that we want to exclude 4 variants (or cart lines) from both the threshold and discount calculations, but given we have two discount ‘candidates’, we’ve had to include the fully formed GID: 2 (candiates) * 2 (condition + target) * 4.
This equates to 43 bytes per GID - 688 bytes per excluded cart line/variant.
The initial output limit is 20kb, for up to 200 cart lines, at which point it scales at 30kb for 300 cart lines, 40kb for 400 cart lines, 50kb for 500 cart lines (roughly through testing).
We can absolutely use this API, but it will only perform for low cart line numbers and/or very few exclusions. The same issue exists with adding variants to other conditions.
My suggestions would be as follows:
- Allow passing only the numeric part of the gid = ~70% reduction in output size (29 bytes per GID)
- Allow an optional top level ‘excludedVariantIds’ property. In our use cases, these values will always be the same across discount candidates, and I imagine many other use cases as well!
- Allow ‘excludedCollections’ as well as ‘excludedVariantIds’
Any one of these change(s)/additions would likely make the order class discount(s) fully scalable across all cart sizes, in a non-breaking way (additive), for a handful of different use cases!