Discussing Shopify Functions development, deployment, and usage in Shopify apps.
Hello,
I have run into what I think is a Shopify Cart API bug in Shopify Functions (Product Discount). I am trying to write a function that discounts items depending on a matching zip code and product variant sku. I have noticed that my function works as expected when viewing the cart, however, once I continue to the checkout page my discounts are no longer applied to the cart.
I have noticed a few things here. When I view the logs for the function run while on the cart page, the cart.deliveryGroups has values in the array. Once I navigate to the checkout, the array is empty. This is where I think the bug lies.
My input.graphql code is as follows:
```
"deliveryGroups": [ {
"deliveryAddress": { "zip": "K4P 0E4"
}
}
],
{ "discounts": [ {
"targets": [ {
"productVariant": { "id": "gid://shopify/ProductVariant/45022386159917"
}
}
],
"value": { "percentage": { "value": "10"
}
}
}
],
"discountApplicationStrategy": "MAXIMUM"
}
Here are the deliveryGroups array and output on the checkout page:"deliveryGroups": [],
{ "discountApplicationStrategy": "MAXIMUM", "discounts": []}
Hi, I was wondering if you found a solution, because I have a similar issue.
I am calculating my discount based on cart attributes. These attributes are passed just fine to function's Input on cart page. Once I proceed to checkout page, the function is called 3 times, and in the last two calls, attributes on cart are all null, which removes the discount.
I am using the typescript template for product discount
Did you get a reply about this issue? I'm having a similar thing where I'm trying to create a product discount based on country code but `deliveryGroups` is always empty.
Thanks for the reply! I've submitted a similar post with my issue too. Nearly three months without a reply doesn't look promising though. 😓