Anchor to orderEditAddVariantorder
orderEditAddVariant
mutation
Requires access scope.
Adds a line item from an existing product variant. As of API version 2025-04, the orderEditAddVariant API will respect the contextual pricing of the variant.
Anchor to Arguments
Arguments
- Anchor to allowDuplicatesallow•
Duplicates BooleanDefault:false Whether the mutation can create a line item for a variant that's already on the calculated order.
- •ID!required
The ID of the calculated order to edit.
- Anchor to locationIdlocation•
Id The ID of the location to check for inventory availability. A default location ID is chosen automatically if none is provided.
- Anchor to quantityquantity•Int!required
The quantity of the item to add to the order. Must be a positive value.
- Anchor to variantIdvariant•
Id ID!required The ID of the variant to add.
Was this section helpful?
Anchor to OrderEditAddVariantPayload returnsOrderEditAddVariantPayload returns
- Anchor to calculatedLineItemcalculated•
Line Item The calculated line item that's added during this order edit.
- Anchor to calculatedOrdercalculated•
Order The calculated order with the edits applied but not saved.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
Mutation Reference
mutation orderEditAddVariant($allowDuplicates: Boolean, $id: ID!, $locationId: ID, $quantity: Int!, $variantId: ID!) {
orderEditAddVariant(allowDuplicates: $allowDuplicates, id: $id, locationId: $locationId, quantity: $quantity, variantId: $variantId) {
calculatedLineItem {
# CalculatedLineItem fields
}
calculatedOrder {
# CalculatedOrder fields
}
userErrors {
field
message
}
}
}
Input
{
"allowDuplicates": true,
"id": "gid://shopify/<objectName>/10079785100",
"locationId": "gid://shopify/<objectName>/10079785100",
"quantity": 1,
"variantId": "gid://shopify/<objectName>/10079785100"
}
{
"allowDuplicates": true,
"id": "gid://shopify/<objectName>/10079785100",
"locationId": "gid://shopify/<objectName>/10079785100",
"quantity": 1,
"variantId": "gid://shopify/<objectName>/10079785100"
}