Anchor to discountCodesCountdiscount
discountCodesCount
query
Requires access scope.
The total number of discount codes for the shop.
Anchor to Arguments
Arguments
- Anchor to queryquery•
A filter made up of terms, connectives, modifiers, and comparators. You can apply one or more filters to a query. Learn more about Shopify API search syntax.
Was this section helpful?
Anchor to Possible returnsPossible returns
- Anchor to CountCount•
Details for count of elements.
Was this section helpful?
- Retrieve the number of discount codes used more than once
- Retrieve the number of discount codes used within a range
- Retrieve the number of unused discount codes
- Retrieve the total number of discount codes
- Retrieves a count of discount codes for a shop
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query discountCodesCount($query: String!) {
discountCodesCount(query: $query) {
count
}
}`,
{
variables: {
"query": "times_used:>1"
},
},
);
const data = await response.json();
query discountCodesCount($query: String!) {
discountCodesCount(query: $query) {
count
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query discountCodesCount($query: String!) { discountCodesCount(query: $query) { count } }",
"variables": {
"query": "times_used:>1"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query discountCodesCount($query: String!) {
discountCodesCount(query: $query) {
count
}
}`,
{
variables: {
"query": "times_used:>1"
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query discountCodesCount($query: String!) {
discountCodesCount(query: $query) {
count
}
}`,
"variables": {
"query": "times_used:>1"
},
},
});
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 discountCodesCount($query: String!) {
discountCodesCount(query: $query) {
count
}
}
QUERY
variables = {
"query": "times_used:>1"
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"query": "times_used:>1"
}
Response
JSON{
"discountCodesCount": {
"count": 3
}
}