Home » Shopify Apps » How to Implement Shopify Discounts through the draftOrder API

How to Implement Shopify Discounts through the draftOrder API

The Shopify’s Discount API enables developers to create, manage, and apply discounts to orders in their Shopify stores. This Shopify Discount API guide helps automate and customize discounts for various scenarios, such as sales and special promotions. Understanding the DraftOrder API for Shopify is crucial for successful Shopify discount implementation.

1. DraftOrder API’s New Features

According to Shopify’s latest release document, the draftOrderCreate API now supports acceptAutomaticDiscounts and allowDiscountCodesInCheckout, which allow you to apply default discounts.

To use these new features, update the API version in index file to the latest version:

Latest  API_VERSION : “2024-07”

2. The Shopify Discount API’s functionalities

Here’s what you can do with Shopify Discount API:

  • Create Discounts: Set up discounts that can be a percentage off, a fixed amount off, or free shipping.
  • Discount Codes: Make discount codes that customers can enter at checkout to get a discount.
  • Automatic Discounts: Set up discounts that apply automatically without needing a code.
  • Rules and Conditions: Define conditions for when discounts apply, like minimum purchase amounts or specific products.
  • Schedule Discounts: Set start and end dates for your discounts.

Combined Discounts: Decide if multiple discounts can be used together or not.

3. Key Parameters for DraftOrder API

acceptAutomaticDiscounts 

If true shopify default admin discounts are applied, if false shopify default admin discounts are not applied. This parameter is central to Shopify discount implementation.

draft-order-api-1
draft-order-api-2
draft-order-api-3

allowDiscountCodesInCheckout 

If true shopify default admin discounts are applied, if false shopify default admin discounts are not applied. This is essential for Apply discounts via Shopify API.

draft-order-api-4
draft-order-api-6

discountCodes  

We can specify a particular discount code that we will attempt to apply to the draft order on the checkout page. Understanding how to manage discount codes is part of the Shopify API for discounts.

draft-order-api-7

Request :

draft-order-api-code-1

Variable :

draft-order-api-code-2

Response :

draft-order-api-code-3

We got the invoice URL and needed to open it in the browser to create a draft order.

Important Note 

We can apply multiple discounts at the same time, such as a discount code and an automatic discount.

draft-order-api-9

Conclusion

By following these steps, you can use the Shopify Discount API with DraftOrder to set up and apply discounts in your Shopify store. This makes it easy to manage promotions and special offers, improving the shopping experience for your customers.

Looking for custom Shopify app development? We can develop the ideal app for your store. Contact us to get started!

Latest Posts

Leave A Comment