discountNode
Returns a discount resource by ID.
Anchor to Possible returnsPossible returns
- Anchor to DiscountNodeDiscount•
Node The
object enables you to manage discounts, which are applied at checkout or on a cart.
Discounts are a way for merchants to promote sales and special offers, or as customer loyalty rewards. Discounts can apply to orders, products, or shipping, and can be either automatic or code-based. For example, you can offer customers a buy X get Y discount that's automatically applied when purchases meet specific criteria. Or, you can offer discounts where customers have to enter a code to redeem an amount off discount on products, variants, or collections in a store.
Learn more about working with Shopify's discount model, including related mutations, limitations, and considerations.
- Querying a non-existent discount returns null
- Retrieve a discount by its ID
Examples
query {
discountNode(id: "gid://shopify/DiscountNode/999999999") {
id
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query { discountNode(id: \"gid://shopify/DiscountNode/999999999\") { id } }"
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query {
discountNode(id: "gid://shopify/DiscountNode/999999999") {
id
}
}`,
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: `query {
discountNode(id: "gid://shopify/DiscountNode/999999999") {
id
}
}`,
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query {
discountNode(id: "gid://shopify/DiscountNode/999999999") {
id
}
}
QUERY
response = client.query(query: query)