discount Code Activatemutation
mutation
2024-10latest
Requires Apps must have write
access scope.
Activates a code discount.
Arguments
The ID of the code discount to activate.
Was this section helpful?
DiscountCodeActivatePayload returns
The activated code discount.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Code examples for MUTATION: discountCodeActivate
Query Reference for MUTATION: discountCodeActivate
"mutation discountCodeActivate($id: ID!) {\n discountCodeActivate(id: $id) {\n codeDiscountNode {\n # DiscountCodeNode fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: discountCodeActivate
"{\n \"id\": \"gid://shopify/<objectName>/10079785100\"\n}"
Schema Reference for MUTATION: discountCodeActivate
""
Display Examples for MUTATION: discountCodeActivate
[ { "example": { "type_name": "discountcodeactivate", "title": "Activate a code discount set to start in the future", "description": "Activating a code discount set to start in the future sets its `startsAt` to now. In this example, the `startsAt` was originally set to January 1, 2049.", "query_string": "mutation discountCodeActivate($id: ID!) {\n discountCodeActivate(id: $id) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n status\n startsAt\n endsAt\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n}", "variables": { "id": "gid://shopify/DiscountCodeNode/206265824" }, "response": { "data": { "discountCodeActivate": { "codeDiscountNode": { "codeDiscount": { "title": "percentage_off_code", "status": "ACTIVE", "startsAt": "2024-09-12T01:06:59Z", "endsAt": "2049-02-01T05:00:00Z" } }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/pricing/test/unit/graph_api/admin/mutations/discount_code_activate_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\": \"mutation discountCodeActivate($id: ID!) { discountCodeActivate(id: $id) { codeDiscountNode { codeDiscount { ... on DiscountCodeBasic { title status startsAt endsAt } } } userErrors { field code message } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/DiscountCodeNode/206265824\"\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation discountCodeActivate($id: ID!) {\n discountCodeActivate(id: $id) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n status\n startsAt\n endsAt\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/DiscountCodeNode/206265824\"\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 mutation discountCodeActivate($id: ID!) {\n discountCodeActivate(id: $id) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n status\n startsAt\n endsAt\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/DiscountCodeNode/206265824\"\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\": `mutation discountCodeActivate($id: ID!) {\n discountCodeActivate(id: $id) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n status\n startsAt\n endsAt\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/DiscountCodeNode/206265824\"\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 mutation discountCodeActivate($id: ID!) {\n discountCodeActivate(id: $id) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n status\n startsAt\n endsAt\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/DiscountCodeNode/206265824\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the code discount to activate.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "id", "argValue": " \"gid://shopify/DiscountCodeNode/206265824\"", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "discountcodeactivate", "title": "Activate an expired code discount", "description": "Activating an expired code discount sets its `endsAt` value to `null`", "query_string": "mutation discountCodeActivate($id: ID!) {\n discountCodeActivate(id: $id) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n status\n startsAt\n endsAt\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n}", "variables": { "id": "gid://shopify/DiscountCodeNode/424668491" }, "response": { "data": { "discountCodeActivate": { "codeDiscountNode": { "codeDiscount": { "title": "EXPIRED10", "status": "ACTIVE", "startsAt": "2024-08-28T01:05:24Z", "endsAt": null } }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/pricing/test/unit/graph_api/admin/mutations/discount_code_activate_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\": \"mutation discountCodeActivate($id: ID!) { discountCodeActivate(id: $id) { codeDiscountNode { codeDiscount { ... on DiscountCodeBasic { title status startsAt endsAt } } } userErrors { field code message } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/DiscountCodeNode/424668491\"\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation discountCodeActivate($id: ID!) {\n discountCodeActivate(id: $id) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n status\n startsAt\n endsAt\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/DiscountCodeNode/424668491\"\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 mutation discountCodeActivate($id: ID!) {\n discountCodeActivate(id: $id) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n status\n startsAt\n endsAt\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/DiscountCodeNode/424668491\"\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\": `mutation discountCodeActivate($id: ID!) {\n discountCodeActivate(id: $id) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n status\n startsAt\n endsAt\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/DiscountCodeNode/424668491\"\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 mutation discountCodeActivate($id: ID!) {\n discountCodeActivate(id: $id) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n status\n startsAt\n endsAt\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/DiscountCodeNode/424668491\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the code discount to activate.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "id", "argValue": " \"gid://shopify/DiscountCodeNode/424668491\"", "typeKind": "MUTATION" } ] } ]