Discussing APIs and development related to customers, discounts, and order management.
Hello,
I am looking to integrate a SaaS platform with Shopify stores as a Partner, aiming to be able to create Discount Code as needed then listing Sales by any given Discount Code.
After going through the docs, I understand that the process would go as follow.
My first question, am I on the right path? Is the above process correct?
I am confused on how to achieve point 3, listing Sales of a Discount Code. According to the docs, it should be doable.
But I cannot find any GraphQL or Rest API to satisfy this request, I've gone through the Admin and Partners APIs to no avail.
However, I accidentally came across the following Admin API endpoint, under Analytics, to retrieve a Sales report but as you can see, the latest stable version 2023-07 does not support it. Going back to an older version 2023-04 does seem to support this functionality, see here.
So was this endpoint deprecated in the latest Admin API version? Is there an alternative you could point me to?
Is there anything you would suggest I do differently?
Thanks in advance.
Kinane.
Hey @Kinane
That sounds like the right path!
For your third point, to list sales by a given discount code, there isn't a direct endpoint. As an (awkward) workaround, you could indirectly get the information by iterating orders.
E.g.:
GET /admin/api/2023-07/orders.json?status=any
Then, in the response, check in each order if the 'discount_codes' array contains the code you're interested in.
Depending on your specific use case, you might also want to look into webhooks to get real-time updates about order creation, which could be useful in terms of keeping track of when and how often your discount codes are being used.
Scott | Developer Advocate @ Shopify
Hi @SBD_
Thank you for your reply.
I see, I am familiar with this endpoint but I am not sure whether this is something we can rely on, due to the nature of the different orders statuses that we'd need to manage; particularly in the case of refunded, unfulfilled and/or canceled orders.
Do you think a combination of `financial_status: paid`, `fulfillment_status: shipped` and `status: closed` is a guarantee that said orders are completed and therefore I am able to safely compute total discount amount by discount code?
Perhaps here I am taking a step away from the main topic although it goes in the same direction.
Is there a way to manage Commissions on Sales as opposed to Discount Codes?
Thank you.
Hey @Kinane
Paid is probably the safest, since paid orders aren't always closed.
> Is there a way to manage Commissions on Sales as opposed to Discount Codes?
Not an easy way but maybe via adding a hidden cart attribute and retrieving it later - but again, more work for you to look through each order and run calculations.
Scott | Developer Advocate @ Shopify