All things Shopify and commerce
For now Shopify only have 2 options for discount
The subtotal of the target order.
The target product variant.
https://shopify.dev/docs/api/functions/reference/order-discounts/graphql/common-objects/target
Do we have any way to set discount on cart item index, instead of the productVairant
In my case, there are 2 items in cart with the same variant. But they have different properties for Private Sale
Input:
{ "cart": { "lines": [ { "id": "gid://shopify/CartLine/0", "quantity": 2, "cost": { "amountPerQuantity": { "amount": "785.95" } }, "merchandise": { "__typename": "ProductVariant", "id": "gid://shopify/ProductVariant/47641613599039", "product": { "id": "gid://shopify/Product/9118075814207" } } }, { "id": "gid://shopify/CartLine/1", "quantity": 1, "cost": { "amountPerQuantity": { "amount": "785.95" } }, "TeamStore_Private": { "value": "$765.95" }, "merchandise": { "__typename": "ProductVariant", "id": "gid://shopify/ProductVariant/47641613599039", "product": { "id": "gid://shopify/Product/9118075814207" } } } ], "buyerIdentity": null } }
Output:
{ "discounts": [ { "targets": [ { "productVariant": { "id": "gid://shopify/ProductVariant/47641613599039", "quantity": 1 } } ], "value": { "fixedAmount": { "amount": 20 } }, "message": "Team Store" } ], "discountApplicationStrategy": "ALL" }
The discount should be affect for the first item has Private Sale instead the second one.
You can't target a specific line item with Functions discounts right now.
There's a popular GitHub discussion thread where devs are requesting this functionality: https://github.com/Shopify/function-examples/discussions/199
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024