Anchor to orderEditAddShippingLineorder
orderEditAddShippingLine
mutation
Requires 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.
Anchor to Arguments
Arguments
- •ID!required
The ID of the calculated order to edit.
- Anchor to shippingLineshipping•
Line OrderEdit requiredAdd Shipping Line Input! The shipping line to be added.
Was this section helpful?
Anchor to OrderEditAddShippingLinePayload returnsOrderEditAddShippingLinePayload returns
- Anchor to calculatedOrdercalculated•
Order The calculated order with the edits applied but not saved.
- Anchor to calculatedShippingLinecalculated•
Shipping Line The calculated shipping line that's added during this order edit.
- Anchor to userErrorsuser•
Errors The list of errors that occurred from executing the mutation.
Was this section helpful?
- Add a shipping line to an order edit
- orderEditAddShippingLine reference
Examples
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 {
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();
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"
}
}
},
},
});
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)
Input variables
JSON{
"id": "gid://shopify/CalculatedOrder/607673083",
"shippingLine": {
"title": "2-Day Shipping",
"price": {
"amount": 19.99,
"currencyCode": "USD"
}
}
}
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"