discount Codes Countquery
query
2024-10latest
Requires read
access scope.
The total number of discount codes for the shop.
Arguments
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?
Count possible returns
Anchor to CountCountDetails for count of elements.
Was this section helpful?
Code examples for QUERY: discountCodesCount
Query Reference for QUERY: discountCodesCount
"{\n discountCodesCount {\n # Count fields\n }\n}"
Input Reference for QUERY: discountCodesCount
Schema Reference for QUERY: discountCodesCount
Display Examples for QUERY: discountCodesCount
[ { "example": { "type_name": "discountcodescount", "title": "Retrieve the number of discount codes used more than once", "description": "Returns the number of discount codes that were used more than once.", "query_string": "query discountCodesCount($query: String!) {\n discountCodesCount(query: $query) {\n count\n }\n}", "variables": { "query": "times_used:>1" }, "response": { "data": { "discountCodesCount": { "count": 3 } } }, "api_name": "admin", "minimum_api_version": "2024-04", "maximum_api_version": "unstable", "location": "/components/pricing/test/unit/graph_api/admin/resolvers/discount_codes_count_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query discountCodesCount($query: String!) { discountCodesCount(query: $query) { count } }\",\n \"variables\": {\n \"query\": \"times_used:>1\"\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query discountCodesCount($query: String!) {\n discountCodesCount(query: $query) {\n count\n }\n }`,\n {\n variables: {\n \"query\": \"times_used:>1\"\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query discountCodesCount($query: String!) {\n discountCodesCount(query: $query) {\n count\n }\n }\nQUERY\n\nvariables = {\n \"query\": \"times_used:>1\"\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query discountCodesCount($query: String!) {\n discountCodesCount(query: $query) {\n count\n }\n }`,\n \"variables\": {\n \"query\": \"times_used:>1\"\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query discountCodesCount($query: String!) {\n discountCodesCount(query: $query) {\n count\n }\n }\nQUERY;\n\n$variables = [\n \"query\" => \"times_used:>1\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [] }, { "example": { "type_name": "discountcodescount", "title": "Retrieve the number of discount codes used within a range", "description": "Returns the number of discount codes that were used more than onceand less than four times.", "query_string": "query discountCodesCount($query: String!) {\n discountCodesCount(query: $query) {\n count\n }\n}", "variables": { "query": "times_used:>1 AND times_used:<4" }, "response": { "data": { "discountCodesCount": { "count": 2 } } }, "api_name": "admin", "minimum_api_version": "2024-04", "maximum_api_version": "unstable", "location": "/components/pricing/test/unit/graph_api/admin/resolvers/discount_codes_count_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query discountCodesCount($query: String!) { discountCodesCount(query: $query) { count } }\",\n \"variables\": {\n \"query\": \"times_used:>1 AND times_used:<4\"\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query discountCodesCount($query: String!) {\n discountCodesCount(query: $query) {\n count\n }\n }`,\n {\n variables: {\n \"query\": \"times_used:>1 AND times_used:<4\"\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query discountCodesCount($query: String!) {\n discountCodesCount(query: $query) {\n count\n }\n }\nQUERY\n\nvariables = {\n \"query\": \"times_used:>1 AND times_used:<4\"\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query discountCodesCount($query: String!) {\n discountCodesCount(query: $query) {\n count\n }\n }`,\n \"variables\": {\n \"query\": \"times_used:>1 AND times_used:<4\"\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query discountCodesCount($query: String!) {\n discountCodesCount(query: $query) {\n count\n }\n }\nQUERY;\n\n$variables = [\n \"query\" => \"times_used:>1 AND times_used:<4\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [] }, { "example": { "type_name": "discountcodescount", "title": "Retrieve the number of unused discount codes", "description": "Returns the number of discount codes that were never used.", "query_string": "query discountCodesCount($query: String!) {\n discountCodesCount(query: $query) {\n count\n }\n}", "variables": { "query": "times_used:0" }, "response": { "data": { "discountCodesCount": { "count": 25 } } }, "api_name": "admin", "minimum_api_version": "2024-04", "maximum_api_version": "unstable", "location": "/components/pricing/test/unit/graph_api/admin/resolvers/discount_codes_count_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query discountCodesCount($query: String!) { discountCodesCount(query: $query) { count } }\",\n \"variables\": {\n \"query\": \"times_used:0\"\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query discountCodesCount($query: String!) {\n discountCodesCount(query: $query) {\n count\n }\n }`,\n {\n variables: {\n \"query\": \"times_used:0\"\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query discountCodesCount($query: String!) {\n discountCodesCount(query: $query) {\n count\n }\n }\nQUERY\n\nvariables = {\n \"query\": \"times_used:0\"\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query discountCodesCount($query: String!) {\n discountCodesCount(query: $query) {\n count\n }\n }`,\n \"variables\": {\n \"query\": \"times_used:0\"\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query discountCodesCount($query: String!) {\n discountCodesCount(query: $query) {\n count\n }\n }\nQUERY;\n\n$variables = [\n \"query\" => \"times_used:0\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [] }, { "example": { "type_name": "discountcodescount", "title": "Retrieve the total number of discount codes", "description": "Returns the total number of discount codes.", "query_string": "query discountCodesCount {\n discountCodesCount {\n count\n }\n}", "response": { "data": { "discountCodesCount": { "count": 29 } } }, "api_name": "admin", "minimum_api_version": "2024-04", "maximum_api_version": "unstable", "location": "/components/pricing/test/unit/graph_api/admin/resolvers/discount_codes_count_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query discountCodesCount { discountCodesCount { count } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query discountCodesCount {\n discountCodesCount {\n count\n }\n }`,\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query discountCodesCount {\n discountCodesCount {\n count\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query discountCodesCount {\n discountCodesCount {\n count\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query discountCodesCount {\n discountCodesCount {\n count\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [] } ]