order Edit Add Shipping Linemutation
mutation
2025-01release candidate
Requires
write_order_edits
access scope.
Adds a shipping line to an existing order. For more information on how to use the GraphQL Admin API to edit an existing order, refer to Edit existing orders.
Arguments
The ID of the calculated order to edit.
The shipping line to be added.
Was this section helpful?
OrderEditAddShippingLinePayload returns
The calculated order with the edits applied but not saved.
Anchor to OrderEditAddShippingLinePayload.calculatedShippingLinecalculatedShipping Line The calculated shipping line that's added during this order edit.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Examples
Hide code
Copy
mutation addShippingLine($id: ID!, $shippingLine: OrderEditAddShippingLineInput!) { orderEditAddShippingLine(id: $id, shippingLine: $shippingLine) { calculatedOrder { id totalOutstandingSet { presentmentMoney { amount currencyCode } } totalPriceSet { presentmentMoney { amount currencyCode } } } calculatedShippingLine { id title price { presentmentMoney { amount currencyCode } } stagedStatus } userErrors { field message } } }
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": "mutation addShippingLine($id: ID!, $shippingLine: OrderEditAddShippingLineInput!) { orderEditAddShippingLine(id: $id, shippingLine: $shippingLine) { calculatedOrder { id totalOutstandingSet { presentmentMoney { amount currencyCode } } totalPriceSet { presentmentMoney { amount currencyCode } } } calculatedShippingLine { id title price { presentmentMoney { amount currencyCode } } stagedStatus } userErrors { field message } } }", "variables": { "id": "gid://shopify/CalculatedOrder/607673083", "shippingLine": { "title": "2-Day Shipping", "price": { "amount": 19.99, "currencyCode": "USD" } } } }'
const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation addShippingLine($id: ID!, $shippingLine: OrderEditAddShippingLineInput!) { orderEditAddShippingLine(id: $id, shippingLine: $shippingLine) { calculatedOrder { id totalOutstandingSet { presentmentMoney { amount currencyCode } } totalPriceSet { presentmentMoney { amount currencyCode } } } calculatedShippingLine { id title price { presentmentMoney { amount currencyCode } } stagedStatus } userErrors { field message } } }`, { variables: { "id": "gid://shopify/CalculatedOrder/607673083", "shippingLine": { "title": "2-Day Shipping", "price": { "amount": 19.99, "currencyCode": "USD" } } }, }, ); const data = await response.json();
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 mutation addShippingLine($id: ID!, $shippingLine: OrderEditAddShippingLineInput!) { orderEditAddShippingLine(id: $id, shippingLine: $shippingLine) { calculatedOrder { id totalOutstandingSet { presentmentMoney { amount currencyCode } } totalPriceSet { presentmentMoney { amount currencyCode } } } calculatedShippingLine { id title price { presentmentMoney { amount currencyCode } } stagedStatus } userErrors { field message } } } QUERY variables = { "id": "gid://shopify/CalculatedOrder/607673083", "shippingLine": { "title": "2-Day Shipping", "price": { "amount": 19.99, "currencyCode": "USD" } } } response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation addShippingLine($id: ID!, $shippingLine: OrderEditAddShippingLineInput!) { orderEditAddShippingLine(id: $id, shippingLine: $shippingLine) { calculatedOrder { id totalOutstandingSet { presentmentMoney { amount currencyCode } } totalPriceSet { presentmentMoney { amount currencyCode } } } calculatedShippingLine { id title price { presentmentMoney { amount currencyCode } } stagedStatus } userErrors { field message } } }`, "variables": { "id": "gid://shopify/CalculatedOrder/607673083", "shippingLine": { "title": "2-Day Shipping", "price": { "amount": 19.99, "currencyCode": "USD" } } }, }, });
use Shopify\Clients\Graphql; $client = new Graphql("your-development-store.myshopify.com", $accessToken); $query = <<<QUERY mutation addShippingLine($id: ID!, $shippingLine: OrderEditAddShippingLineInput!) { orderEditAddShippingLine(id: $id, shippingLine: $shippingLine) { calculatedOrder { id totalOutstandingSet { presentmentMoney { amount currencyCode } } totalPriceSet { presentmentMoney { amount currencyCode } } } calculatedShippingLine { id title price { presentmentMoney { amount currencyCode } } stagedStatus } userErrors { field message } } } QUERY; $variables = [ "id" => "gid://shopify/CalculatedOrder/607673083", "shippingLine" => [ "title" => "2-Day Shipping", "price" => [ "amount" => 19.99, "currencyCode" => "USD", ], ], ]; $response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{ "id": "gid://shopify/CalculatedOrder/607673083", "shippingLine": { "title": "2-Day Shipping", "price": { "amount": 19.99, "currencyCode": "USD" } } }
Hide code
Response
JSON
{ "orderEditAddShippingLine": { "calculatedOrder": { "id": "gid://shopify/CalculatedOrder/607673083", "totalOutstandingSet": { "presentmentMoney": { "amount": "19.99", "currencyCode": "USD" } }, "totalPriceSet": { "presentmentMoney": { "amount": "31.49", "currencyCode": "USD" } } }, "calculatedShippingLine": { "id": "gid://shopify/CalculatedShippingLine/52c5ee83-d24a-4a4d-a048-b00ad90aa19f", "title": "2-Day Shipping", "price": { "presentmentMoney": { "amount": "19.99", "currencyCode": "USD" } }, "stagedStatus": "ADDED" }, "userErrors": [] } }