Welcome to the Shopify Discount Code Creation Template! This template is designed to help you easily create price rules and discount codes for your Shopify store using the Shopify Admin API. With this template, you can provide a base set of data for the price rule and optionally include additional fields to customize the rule further. The process is secure and straightforward, as the Shopify Admin API token is taken from environment secrets within the Lazy Builder.
To begin using this template, simply click on "Start with this Template" in the Lazy Builder interface. This will pre-populate the code in the Lazy Builder interface, so you won't need to copy, paste, or delete any code.
Before you can use this template, you'll need to set up an environment secret for the Shopify Admin API token. Here's how to do it:
SHOPIFY_ADMIN_API_TOKEN
and paste the API token you copied as the value.Once you have set up the environment secret, you can deploy the app by pressing the "Test" button. This will begin the deployment of the app and launch the Lazy CLI.
After pressing the "Test" button, the Lazy App's CLI interface will appear. If the template requires user input, you will be prompted to provide the necessary information through the CLI. This may include the Shopify store URL, price rule details, and discount code information.
After the app is deployed, Lazy will provide you with a dedicated server link to use the API. If you're using FastAPI, you will also receive a link to the API documentation. You can use these links to interact with the app and create price rules and discount codes for your Shopify store.
If you need to integrate this app into an external service or frontend, you can use the server link provided by Lazy. For example, you might want to add the API endpoints to a custom dashboard or use them in conjunction with other tools that support API requests.
Here's a sample request to create a price rule:
POST /create_price_rule
Host: [Your Lazy Server Link]
Content-Type: application/json
{
"shopify_store_url": "yourstore.myshopify.com",
"base_data": {
"title": "10% Off Everything",
"value": "-10.0",
"starts_at": "2023-01-01T00:00:00Z"
}
}
And here's a sample response you might receive:
{
"price_rule_id": "1234567890"
}
Remember to replace [Your Lazy Server Link]
with the actual server link provided by Lazy and yourstore.myshopify.com
with your actual Shopify store URL.
By following these steps, you can quickly set up and use the Shopify Discount Code Creation Template on the Lazy platform to enhance your Shopify store's promotional capabilities.