Version: 2024-01
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation discountCodeFreeShippingUpdate($freeShippingCodeDiscount: DiscountCodeFreeShippingInput!, $id: ID!) { discountCodeFreeShippingUpdate(freeShippingCodeDiscount: $freeShippingCodeDiscount, id: $id) { codeDiscountNode { id codeDiscount { ... on DiscountCodeFreeShipping { title startsAt endsAt minimumRequirement { ... on DiscountMinimumSubtotal { greaterThanOrEqualToSubtotal { amount currencyCode } } } codes(first: 2) { nodes { code } } } } } userErrors { field code message } } }\",\n \"variables\": {\n \"freeShippingCodeDiscount\": {\n \"code\": \"FRSHP25\",\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": 25.0\n }\n },\n \"startsAt\": \"2022-08-01\",\n \"endsAt\": \"2022-08-08\",\n \"title\": \"Free shipping for orders above $25\"\n },\n \"id\": \"gid://shopify/DiscountCodeFreeShipping/445378512\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation discountCodeFreeShippingUpdate($freeShippingCodeDiscount: DiscountCodeFreeShippingInput!, $id: ID!) {\n discountCodeFreeShippingUpdate(freeShippingCodeDiscount: $freeShippingCodeDiscount, id: $id) {\n codeDiscountNode {\n id\n codeDiscount {\n ... on DiscountCodeFreeShipping {\n title\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n currencyCode\n }\n }\n }\n codes(first: 2) {\n nodes {\n code\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }`,\n \"variables\": {\n \"freeShippingCodeDiscount\": {\n \"code\": \"FRSHP25\",\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": 25.0\n }\n },\n \"startsAt\": \"2022-08-01\",\n \"endsAt\": \"2022-08-08\",\n \"title\": \"Free shipping for orders above $25\"\n },\n \"id\": \"gid://shopify/DiscountCodeFreeShipping/445378512\"\n },\n },\n});\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 discountCodeFreeShippingUpdate($freeShippingCodeDiscount: DiscountCodeFreeShippingInput!, $id: ID!) {\n discountCodeFreeShippingUpdate(freeShippingCodeDiscount: $freeShippingCodeDiscount, id: $id) {\n codeDiscountNode {\n id\n codeDiscount {\n ... on DiscountCodeFreeShipping {\n title\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n currencyCode\n }\n }\n }\n codes(first: 2) {\n nodes {\n code\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"freeShippingCodeDiscount\": {\n \"code\": \"FRSHP25\",\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": 25.0\n }\n },\n \"startsAt\": \"2022-08-01\",\n \"endsAt\": \"2022-08-08\",\n \"title\": \"Free shipping for orders above $25\"\n },\n \"id\": \"gid://shopify/DiscountCodeFreeShipping/445378512\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation discountCodeFreeShippingUpdate($freeShippingCodeDiscount: DiscountCodeFreeShippingInput!, $id: ID!) {\n discountCodeFreeShippingUpdate(freeShippingCodeDiscount: $freeShippingCodeDiscount, id: $id) {\n codeDiscountNode {\n id\n codeDiscount {\n ... on DiscountCodeFreeShipping {\n title\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n currencyCode\n }\n }\n }\n codes(first: 2) {\n nodes {\n code\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"freeShippingCodeDiscount\" => [\n \"code\" => \"FRSHP25\",\n \"minimumRequirement\" => [\n \"subtotal\" => [\n \"greaterThanOrEqualToSubtotal\" => 25.0,\n ],\n ],\n \"startsAt\" => \"2022-08-01\",\n \"endsAt\" => \"2022-08-08\",\n \"title\" => \"Free shipping for orders above $25\",\n ],\n \"id\" => \"gid://shopify/DiscountCodeFreeShipping/445378512\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation discountCodeFreeShippingUpdate($freeShippingCodeDiscount: DiscountCodeFreeShippingInput!, $id: ID!) {\n discountCodeFreeShippingUpdate(freeShippingCodeDiscount: $freeShippingCodeDiscount, id: $id) {\n codeDiscountNode {\n id\n codeDiscount {\n ... on DiscountCodeFreeShipping {\n title\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n currencyCode\n }\n }\n }\n codes(first: 2) {\n nodes {\n code\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }`,\n {\n variables: {\n \"freeShippingCodeDiscount\": {\n \"code\": \"FRSHP25\",\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": 25.0\n }\n },\n \"startsAt\": \"2022-08-01\",\n \"endsAt\": \"2022-08-08\",\n \"title\": \"Free shipping for orders above $25\"\n },\n \"id\": \"gid://shopify/DiscountCodeFreeShipping/445378512\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation discountCodeFreeShippingUpdate($freeShippingCodeDiscount: DiscountCodeFreeShippingInput!, $id: ID!) {\n discountCodeFreeShippingUpdate(freeShippingCodeDiscount: $freeShippingCodeDiscount, id: $id) {\n codeDiscountNode {\n id\n codeDiscount {\n ... on DiscountCodeFreeShipping {\n title\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n currencyCode\n }\n }\n }\n codes(first: 2) {\n nodes {\n code\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n}"
input: { "freeShippingCodeDiscount": { "code": "FRSHP25", "minimumRequirement": { "subtotal": { "greaterThanOrEqualToSubtotal": 25.0 } }, "startsAt": "2022-08-01", "endsAt": "2022-08-08", "title": "Free shipping for orders above $25" }, "id": "gid://shopify/DiscountCodeFreeShipping/445378512" }
response: { "data": { "discountCodeFreeShippingUpdate": { "codeDiscountNode": { "id": "gid://shopify/DiscountCodeNode/445378512", "codeDiscount": { "title": "Free shipping for orders above $25", "startsAt": "2022-08-01T00:00:00Z", "endsAt": "2022-08-08T00:00:00Z", "minimumRequirement": { "greaterThanOrEqualToSubtotal": { "amount": "25.0", "currencyCode": "USD" } }, "codes": { "nodes": [ { "code": "FRSHP25" } ] } } }, "userErrors": [] } } }