Topics covering webhook creation & management, event handling, Pub/Sub, and Eventbridge, in Shopify apps.
(reposting in correct category)
Hi All,
We have a discount code that gives customers 100% off a certain product when applied. When we get the checkout webhook we can see that the discount has been applied but there is no indication that the discount was applied to the product so our system shows the checkout item as full price:
You can see the discount applied and the Free Thingy test product is shown as free:
But the webhook doesn't provide this information, notice the applied_discounts field is empty and the price is shown as the full amount.
Even though the discount has been registered:
Is this some kind of issue in the webhook or is this intentional? If it's intentional is there any way we can detect that the discount applies to the product without having to fetch the discount info from the API and manually check the related products?
Thanks!
Mike
Hey @ant-fx.
This is expected.
applied_discounts on line_items makes reference to, as you'd guess, line item level discounts. Discounts applied via discount codes, while in the checkout interface might appear to be line item level discounts because they target a specific product, are in fact checkout-level discounts. You can only apply one discount code which applies itself to the cart (checking for the applicable product), but you can have multiple line item level discounts. This is why you're seeing it in discount_applications on the cart level, because it's still technically applied to the cart.
The main way in which line item level discounts are applied would be through Shopify POS, where at the discretion of the merchant, they can discount a line item by hand, not through a discount code.
I hope that helps!
Cheers.
Alex | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Hi Alex,
Thanks for your explanation.
In that case how would it be possible for us to correctly display the cart contents and match it to the subtotal of the cart. In my original example the products are shown as 150 and 12 (for a total of 162) but the cart total is 150.
So it seems impossible for us to correctly show the cart contents + total the same way it's shown in the Shopify checkout page as below?
It seems there is no way for us to know at the checkout that the Free Thingy item is free without trying to get the applied price rule and figure it out ourselves?
Given the discount code, you could perform a discount code lookup request, which will return a location header for where you can locate the discount code itself. The part you're going to be most interested in is the price rule that discount code is nested in. If you make a followup request to get the JSON for that price rule, you'll be able to see its defined behaviour (targeted variants and how much for example), and should be able to use that information to reconstruct an accurate interface.
https://help.shopify.com/en/api/reference/discounts/discountcode#show-2019-10
I hope that helps a bit.
Cheers.
Alex | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog