If you missed it at Unite this year, we've exposed line level discount information on the Order API with a new readable property: discount_applications. Take a look at the updated Order API reference for all of the details. This feature will enable more accurate accounting when discounts are involved in orders.
We look forward to seeing what features this enables, as always please leave questions and comments in the thread below.
Shopify Apps Team
The penny allocation bug is now fixed. I checked with your order and the amounts add up.
As for the first issue you mentioned, we have decided to not backfill those orders at this time as those were created as is by clients and this could have unintended side-effects.
Hi again Felix,
We found another issue which is slightly different.
It concerns an order created with the API so I suspect it's a problem with the order data, but Shopify did let it through.
The order has a non zero order.total_discounts but it has no discount codes.
There are no discount applications. I guess it makes given your earlier comment that discount_codes.amount has precedence.
However, clearly, total_discounts was not calculated from discount_codes.amount, as you had also mentioned, and we end up with an inconsistent order.
The order id is 604345466923.
Good observation, discount_codes.amount has precendence when both are provided, but total_discounts can still be provided by clients even if there no actual discount on the order (total_discounts usually being the calculated sum of existing discounts). This has been the case for a long time as well as orders are usually imported "as is".
In best of worlds, clients should not be able to send total_discounts, but ignoring the field could be problematic.
We will come up with a solution and get back to you. One possibility I see would be to create a manual discount allocated across all line items if no discount is explicitly provided but total_discounts is.
Helllo all, do you guys a sample JSON request that makes use of the discount_applications and discount_allocations? I have not yet been sucessuly been able to create one that works :-S
Hey Chris! The API is read-only. There is no way to write discount applications and allocations directly. You need to go through the existing interface for this which will end up creating a discount application.
Thanks for the reply Felix. That is so unfortunate :( - I really wish the Shopify Reference guide was a bit more cleat as to what data elements are read-only vs not - and in which operations, it would have saved me a lot of time.
Is Shopify Planing on making these APIs usable via the POST Order API any time soon?
Our integration of the Klarna Payments gateways uses the Shopify Checkout object to display order data (order total, discount, shipping, tax, etc.) on our hosted page and also to create the Klarna order. In order to accurately support orders with Automatic Discounts, we need the automatic discount data to be available on the Checkout object prior to the customer completing the order. Currently when a customer selects on of our gateways as a payment method, the customer is redirected to our hosted page, which uses the API data to display checkout prices. Currently Automatic Discount data is not available in the Checkout object at the point in time when the customer is redirected to our hosted page. As soon as the order is created in Shopify (which we create using the Shopify REST API), the Checkout object would then get updated with the discount data (in applied_discount field), but that is too late for our integration. If helpful, feel free to see the flow at our Klarna Shopify demo store. Can you help us determine how we access the Automatic Discount data prior to the customer placing the order? thanks!