---
title: "How to Create Automatic Discounts in Shopify Remix Using GraphQL?"
url: "https://magecomp.com/blog/create-automatic-discounts-in-shopify-remix-using-graphql/"
date: "2025-06-23T13:16:08+00:00"
modified: "2025-06-23T13:16:11+00:00"
author:
  name: "Bharat Desai"
  url: "https://magecomp.com"
categories:
  - "Remix"
  - "Shopify"
word_count: 590
reading_time: "3 min read"
summary: "Generating automatic discounts via code enhances Shopify app developers’ ability to provide dynamic, personalized promotion strategies, automatically. Developers that are using Shopify Remix and ..."
description: "Learn how to create automatic discounts in Shopify using GraphQL within a Remix app."
keywords: "Remix, Shopify"
language: "en"
schema_type: "Article"
related_posts:
  - title: "Best Shopify Themes for 2026 (Beautiful &amp; Responsive)"
    url: "https://magecomp.com/blog/best-shopify-themes/"
  - title: "How To Drive Traffic and Sales To Your Shopify Store"
    url: "https://magecomp.com/blog/drive-traffic-and-sales-to-shopify-store/"
  - title: "How to Set Wholesale &amp; B2B Minimum Order Quantities and Customer Limits on Shopify"
    url: "https://magecomp.com/blog/wholesale-b2b-order-limits-shopify/"
---

# How to Create Automatic Discounts in Shopify Remix Using GraphQL?

_Published: June 23, 2025_  
_Author: Bharat Desai_  

![How to Create Automatic Discounts in Shopify Remix Using GraphQL](https://magecomp.com/blog/wp-content/uploads/2025/06/How-to-Create-Automatic-Discounts-in-Shopify-Remix-Using-GraphQL-1024x512.webp)

Generating automatic discounts via code enhances Shopify app developers’ ability to provide dynamic, personalized promotion strategies, automatically. Developers that are using Shopify Remix and the Admin GraphQL API can create automatic discounts (i.e “$10 off $100 purchase”) programmatically, right from their own custom admin UI and/or backend logic.

[![Shopify Development Services](https://magecomp.com/blog/wp-content/uploads/2025/01/Shopify-Development-Services.webp)](https://magecomp.com/services/shopify-development-service/)

## Why Use GraphQL for Discounts?
The GraphQL Admin API is the most straightforward way to create, retrieve and manage discounts, especially on scale. It gives you the ability to:

- Remove repetitive manual setup
- Dynamically apply discounts
- Build custom admin interfaces or automation

## What We’re Building
We will build a GraphQL mutation that creates an automatic discount:

“Get $10 off on orders over $100, combinable with shipping discounts.”

## Step-by-Step Setup in Shopify Remix
### Authenticate the Admin API
In your app using Shopify Remix, authenticate the Admin API with authenticate.admin(request), here’s how it works:

```
import { authenticate } from "../shopify.server";

export async function action({ request }: ActionArgs) {
  const { admin } = await authenticate.admin(request);

  const response = await admin.graphql(
    `#graphql
    mutation discountAutomaticBasicCreate($automaticBasicDiscount: DiscountAutomaticBasicInput!) {
      discountAutomaticBasicCreate(automaticBasicDiscount: $automaticBasicDiscount) {
        automaticDiscountNode {
          id
          automaticDiscount {
            ... on DiscountAutomaticBasic {
              title
              startsAt
              combinesWith {
                productDiscounts
                shippingDiscounts
                orderDiscounts
              }
              minimumRequirement {
                ... on DiscountMinimumSubtotal {
                  greaterThanOrEqualToSubtotal {
                    amount
                    currencyCode
                  }
                }
              }
              customerGets {
                value {
                  ... on DiscountAmount {
                    amount {
                      amount
                      currencyCode
                    }
                  }
                }
                items {
                  ... on AllDiscountItems {
                    allItems
                  }
                }
              }
            }
          }
        }
        userErrors {
          field
          code
          message
        }
      }
    }`,
    {
      variables: {
        automaticBasicDiscount: {
          title: "$10 off orders over $100 (combinable with shipping discounts)",
          startsAt: new Date().toISOString(),
          minimumRequirement: {
            subtotal: {
              greaterThanOrEqualToSubtotal: "100.00"
            }
          },
          customerGets: {
            value: {
              discountAmount: {
                amount: "10.00",
                appliesOnEachItem: false
              }
            },
            items: {
              all: true
            }
          },
          combinesWith: {
            productDiscounts: false,
            shippingDiscounts: true,
            orderDiscounts: false
          }
        }
      }
    }
  );

  const data = await response.json();

  if (data.data.discountAutomaticBasicCreate.userErrors.length > 0) {
    console.error("Discount creation error:", data.data.discountAutomaticBasicCreate.userErrors);
    return { success: false, errors: data.data.discountAutomaticBasicCreate.userErrors };
  }

  return { success: true, discountId: data.data.discountAutomaticBasicCreate.automaticDiscountNode.id };
}
```

### What This Code Does?
- Authenticates the admin API with authenticate.admin(request)
- Runs the discountAutomaticBasicCreate mutation
- Passes all required discount fields, including:

Title

Start date

Discount value and rules

Combination settings

- Returns the discount Id, if there is an error it returns the error

### Testing the Discount
1. For testing, either deploy your Remix app or run it locally
2. Submit the form or trigger the mutation via your custom admin route
3. Check the Shopify Admin → Discounts section to see the new automatic discount

### Required Permissions
Be sure your app has the following Admin API scopes:

- write_discounts
- read_discounts

You can set this in your app’s shopify.app.toml or admin UI.

## Conclusion
In Shopify Remix, implementing discounts using GraphQL provides unmatched reign and automation. You can create a UI where store admins define their rules or run it conditionally through server-side logic.

This setup is perfect for:

- Custom promotions
- Automated sales campaigns
- Discount A/B testing systems

[![Hire Shopify Developers](https://magecomp.com/blog/wp-content/uploads/2024/12/Hire-Shopify-Developers-png.webp)](https://magecomp.com/services/expert-shopify-developers/)

## FAQ
1. **Can I set up automatic discounts in Shopify without using GraphQL or any code?**

Absolutely! You can set up basic automatic discounts from the Shopify Admin dashboard. When creating discounts this way you will have limitations related to automatic discounts compared to code-based automatic discounts using GraphQL and Shopify Functions.

2. **How do I add an automatic discount on Shopify without GraphQL?**

You are able to set up automatic discounts from the Admin section of your Shopify store.

Steps:

- Go to Shopify Admin > Discounts
- Click Create Discount
- Select Automatic Discount
- Set the following:

Discount name

Type: Percentage, Fixed amount, Buy X Get Y

Conditions: Product, quantity, or order value

Start & end date

- Click Save

3. **Can I have more than one automatic discount applied at the same time?**

No. Shopify limits you to one automatic discount per customer to use at a time – it does not matter if the discount was created in the admin section or programmatically.


---

_View the original post at: [https://magecomp.com/blog/create-automatic-discounts-in-shopify-remix-using-graphql/](https://magecomp.com/blog/create-automatic-discounts-in-shopify-remix-using-graphql/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-10-01 12:58:57 UTC_  
