Hi!
We are trying to figure out the formula/logic how to calculate resulting price of the Order Line Item - the same value seen in the Shopify back-end UI.
Admin REST API does not return the resulting price - instead it returns the following values which put together can probably get the expected result but there is no documented formula/logic for that:
- price
- total_discount
- discount_allocations
We have 2x different Shopify instances in context where we see the following from Shopify Admin REST API “/orders/$id.json” response:
- in one case:
- price is 130 EUR
- total_discount is 0.00
- discount_allocations array has a single entry of 26 EUR
- which goes in hand with the value seen in the UI => 104 EUR
- in another case
- price is 45 EUR
- total_discount is 45 EUR
- discount_allocations array has a single entry of 45 EUR
- which goes in hand with the value seen in the UI => 0 EUR (it is a freebie)
We would assume based on the naming alone the formula could be: price - total_discount = resulting price but this is clearly not the case. We could assume that deducting all the discount_allocations entries would give us the result obviously we cant be 100% sure (there could be some other edge cases etc.). It
s very weird that mentioned API does not has an attribute which represents the resulting price to be used as-is.
We would very much appreciate a valid 100% correct formula/logic how to determine the resulting price of each Order Line Item.