How can I apply discount on line_items when im create a new order using REST Admin Order API?
I've tried to set almost every possible keys available in the line_items. And my requirement must be an Order, not DraftOrder.
I've even tried to create first, then later update the line_items with discount but still no avail.
I'm open for GraphQL API solution as I'm using this package in my application >> https://github.com/MONEI/Shopify-api-node
Hope someone has done similar thing. Thanks
Hey there @ikkifujiwara
I've looked into this and presently this is not possible using the Orders API. In Storefront API, (checkoutDiscountCodeApplyV2 mutation would apply an existing discount to a checkout) - that's seemingly the closest we've got to what you're looking for.
It's mentioned that Discounts can't be applied to specific items within an Order in the Orders CSV docs strangely enough, I'll look at getting this same mention into the API docs.
I've noted that there are other partners who are looking for the same functionality and I've made this known to the product team today. If there's any future updates, they'll be communicated via the Shopify Community forums and via our Developer Changelog. Hope that explains things at least!
I would appreciate if either of you could clarify how to go about creating and order and adding discounts to line items through APIs.
Would it be something like this?
1. Create an order through Admin API
2. Get its associated checkout id and apply discount codes through the Storefront API
My problem is that when I create an order, the checkout id is null, so I don't know how to do the second step.
Thanks a lot!
If you are importing completed orders with the REST Admin API directly into a store then there wouldn't be any checkout ID associated with it.
If you are looking to use the Storefront API to build a customer's cart and apply discount codes, then your app should refer the customer to the checkout URL, where the Order will be created after their transaction is complete.
The documentation on how to Create and update a cart with the Storefront API should help get started, then you would also need to use the cartDiscountCodesUpdate mutation before redirecting the customer.
All the best,
Hi, when we create and update a cart with the storefront API can we pass the processed_at date so the order is registered as when it took place in the past, since we are trying to import old orders into shopify, but the challenge is that old orders allowed for individual line_item discounts to be applied.