Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.

Product discount information missing in checkout webhook?

ant-fx
Shopify Partner
20 0 0

(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:

 

discount1.png

 

You can see the discount applied and the Free Thingy test product is shown as free:

 

discount2.png

 

But the webhook doesn't provide this information, notice the applied_discounts field is empty and the price is shown as the full amount.

 

discount3.png

 

Even though the discount has been registered:

 

discount4.png

 

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

Replies 3 (3)

Alex
Shopify Staff
1561 81 341

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

ant-fx
Shopify Partner
20 0 0

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?

 

discount2.png

 

Alex
Shopify Staff
1561 81 341

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