Main issue: Automate creation of Shopify discount codes from an external employee management system when a new member is added.
Key guidance provided:
This is possible via the Shopify Admin API.
Setup: create a private app in each Shopify store with permissions to manage discounts.
Implementation: call the REST endpoint POST /admin/api/2022-10/price_rules/{price_rule_id}/discount_codes.json with required parameters to create a code under a specific price rule (a price rule defines the discount’s conditions/values).
Trigger: integrate this API call in the external system upon member creation.
Reference: a screenshot shows an example POST request; link to official API docs was provided.
Latest development:
The requester asked how to handle multiple clients, each with their own store, and whether a private app can be associated with each client’s store/account in their system.
Status and open questions:
No confirmed answer yet on multi-store/app association strategy (e.g., per-store private/custom app installs and credential management).
I have an employee management system that is external and not connected to Shopify.
My clients have requested a new feature and I’m trying to figure out if it’s possible.
When adding a new member to their account on my site they would like to create a discount code for that member. When the code is entered on my site it should automatically create that code in their Shopify account.
Yes, it is possible to automatically create a discount code in a Shopify store using the Shopify API. Here is an overview of how you can do this:
First, you will need to create a private app in your Shopify store to access the API. To do this, go to “Apps” in the Shopify admin, and click on “Manage private apps”. Then, click on “Create a new private app” and follow the prompts to set up the app. Make sure to give the app the necessary permissions to create discount codes.
Next, you will need to use the Shopify API to create a discount code in your store. You can do this by making a POST request to the /admin/api/2022-10/price_rules/507328175/discount_codes.json endpoint, passing in the necessary parameters in the request body. For example:
In your employee management system, you can then create a function that makes the API request to create the discount code when a new member is added to the system.
Thanks for the great response! Each of my clients will have their own stores so I am assuming we could associate the private app in each of their stores to their account with us using the api?