In Shopify, if you want to create a Discount, firstly, you need to create a Price rule using Postman. The price rule will allow you to know what value the discount is and when and how you can apply it to customers.
Price rules have 2 ingredients: Entitlements and prerequisites. You can understand as follows:
Â
-
- Entitlements are the precise resources to which a discount applies, such as goods, variations, or collections.Â
-
- Prerequisites are the conditions that must be satisfied for the discount to apply to the eligible resources.
Example: Free Shipping for all customers buying over $50.
I will show you how to create a price rule that gives the buyer $10 for an order.Â
Step 1: Generate API credentials from the Shopify admin
Â
-
- Log in to your Shopify admin
-
- Go to Apps – Manage private apps
Â
-
- Click Create a new private app
-
- In the App details section, enter a name for your app, and an emergency developer email.
-
- In the Admin API section, select the areas of your store that you want the app to access
Â
-
- Click Save
The Admin API section displays the app’s API key and password when you save the app’s details.
Shopify Brivity Integration
Shopify Oracle Integration
Shopify Zalo-oa Integration
Shopify Tiki Integration
Step 2: Create A Price Rule Using Postman In Shopify
Â
-
- Log in to your Postman and create a new workspace
-
- Create a new POST with this URL:
https://{username}:{password}@{shop}.myshopify.com/admin/api/{api-version}/{resource}.json
Â
-
- {username} – The API key that you generated.
-
- {password} – The API password that you generated.
-
- {shop} – The name of your development store.
-
- {api-version} – The supported API version that you want to use.
-
- {resource} – A resource endpoint from the REST Admin API.
Or you can copy this example in the Shopify Admin, remember to change {resource} to {price_rules}:
https://33a72f01e02987636e1c1a9a4e95c840:[email protected]/admin/api/2021-10/price_rules.json
Â
-
- Paste the URL above.
In the body section, enter this code, then click Send.
{
"price_rule": {
"title": "SUMMERSALE10OFF",
"target_type": "line_item",
"target_selection": "all",
"allocation_method": "across",
"value_type": "fixed_amount",
"value": "-10.0",
"customer_selection": "all",
"starts_at": "2021-12-10T13:00:10Z"
}
}
Explain of parameters in the payload:Â
Â
-
- {Target_type} – There are 2 types: line_item and shipping_line
-
- {Target_selection} – There are 2 selections: all and entitled
-
- {allocation_method} – There are 2 methods (Each method: The discount is applied to each of the entitled items. Cross method: The calculated discount amount will be applied across the entitled items)
-
- {value_type} – It can be a percentage, a fixed amount, or free shipping
-
- {value} – The number of the discount value
-
- {customer_selection} – There are 2 selections: All and Prerequisite
-
- {starts_at} – The date and time when the price rule was created.
Response:
The API will return all information about the created price rule.
I have shown you all steps to create a price rule with Shopify API using Postman. If you have any questions, please comment below or refer to our Devdocs.Â
If you still do not understand the tutorial’s content, you can watch the video below for a more overview.
Hopefully, you can do it!