Get lineitem discounted unit price

_SZ
Tourist
3 0 2

Hi guys ..

 

We've developed an integration for a client with a 3PL partner, the integration handles the usual logistical aspects including managing refunds.

So one we get a request to refund an item, we'd fetch the GraphqlOrder & Look for the specified item and then use the value of discountedUnitPrice to calculate the refund amount.

 

This mostly works, except for cases when the line item is discounted (discount code or shopify script), in which case, the discountedUnitPrice value equals the originalUnitPrice

So we'd better use the originalUnitPrice instead & calculate the discounted unit price manually using the discountAllocations property.

 

My question is : Is this is expected behaviour for discountedUnitPrice ? or is it a bug from the Graphql API ?

 

Thank you.

 

 

Replies 11 (11)
polozerance
Tourist
4 0 3

I experienced a similar issue.

Is it possible to have an official response from Shopify about this MAJOR ISSUE that is impacting calculation of the amount of refunds on discounted products 

Regards

SBD_
Shopify Staff
Shopify Staff
1098 146 219

Hey @_SZ 

discountedUnitPrice should indeed be the discounted price: "The price of a single variant unit after line item discounts are applied in shop and presentment currencies."

I'm unable to replicate on a test store - can you please provide an example shop/order ID?

Scott | Developer Support @ 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 Shopify.dev or the Shopify Web Design and Development Blog

_SZ
Tourist
3 0 2

Hey SBD_,

 

Here are 2 examples for Shop (40728559766) :

- 3741155852438 : the discount applied through the discount code applies to specific items

- 3730827673750 : the discount is applied to the entier shopping cart.

 

In both cases the value of  discountedUnitPrice each line itme equals that of originalUnitPrice.

 

Thank you for your help in advance

_SZ
Tourist
3 0 2

@SBD_, please let me know if the provided examples are helpful, or if you need any more information.

 

- Thanks

SBD_
Shopify Staff
Shopify Staff
1098 146 219

Hey @_SZ 

That does seem inaccurate. Thanks for flagging this, I've raised an issue internally.

For the meantime, continue using the discountAllocations workaround.

Scott | Developer Support @ 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 Shopify.dev or the Shopify Web Design and Development Blog

SBD_
Shopify Staff
Shopify Staff
1098 146 219

Hey @_SZ 

The pricing team have confirmed this is a bug. Will have more information soon.

Scott | Developer Support @ 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 Shopify.dev or the Shopify Web Design and Development Blog

xmimoun
New Member
4 0 0

Hello, any updates on that thread ?

tolgapaksoy
Shopify Partner
91 7 55

@SBD_any update on this? It's been a confirmed bug for 2 months now. Thanks!

SBD_
Shopify Staff
Shopify Staff
1098 146 219

Checking in on this one. Get back to you soon.

Scott | Developer Support @ 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 Shopify.dev or the Shopify Web Design and Development Blog

SBD_
Shopify Staff
Shopify Staff
1098 146 219

Pricing team have so far been unable to prioritise a fix. Although they did say "It is recommended to use discountAllocations moving forward".

Let you know as I hear more.

Scott | Developer Support @ 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 Shopify.dev or the Shopify Web Design and Development Blog

SBD_
Shopify Staff
Shopify Staff
1098 146 219

There's been some further discussion clarifying the confusion:

discountedUnitPrice(Set) is the unit price of the LineItem after line item level discount, but without Order level discount. The field name could be misleading. Since we can't easily change the field name in a public API, I've updated the documentation for the field discountedUnitPriceSet to explicitly call out the fact that it does not include any Order level discounts.

And if merchants want to know the line item after order discount unit price, without intending to use that value to refund the customer, then discountAllocations is the way to go. However, merchants still should not use that to issue refunds, as that does not take into consideration any taxes. To refund, use Order.suggestedRefund.

 

Scott | Developer Support @ 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 Shopify.dev or the Shopify Web Design and Development Blog