Anchor to locationDeactivatelocation
locationDeactivate
mutation
Requires access scope.
Deactivates a location and moves inventory, pending orders, and moving transfers to a destination location.
Anchor to Arguments
Arguments
- Anchor to destinationLocationIddestination•
Location Id The ID of a destination location to which inventory, pending orders and moving transfers will be moved from the location to deactivate.
- Anchor to locationIdlocation•
Id ID!required The ID of a location to deactivate.
Was this section helpful?
Anchor to LocationDeactivatePayload returnsLocationDeactivatePayload returns
- Anchor to locationlocation•
The location that was deactivated.
- Anchor to locationDeactivateUserErrorslocation•
Deactivate User Errors [LocationDeactivate non-nullUser Error!]! The list of errors that occurred from executing the mutation.
Was this section helpful?
- Deactivate a location with active inventory
- Deactivate a location with pending orders
- Deactivate an active location
- locationDeactivate reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation locationDeactivate {
locationDeactivate(locationId: "gid://shopify/Location/922479430") {
location {
id
isActive
}
locationDeactivateUserErrors {
message
code
field
}
}
}`,
);
const data = await response.json();
mutation locationDeactivate {
locationDeactivate(locationId: "gid://shopify/Location/922479430") {
location {
id
isActive
}
locationDeactivateUserErrors {
message
code
field
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation locationDeactivate { locationDeactivate(locationId: \"gid://shopify/Location/922479430\") { location { id isActive } locationDeactivateUserErrors { message code field } } }"
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation locationDeactivate {
locationDeactivate(locationId: "gid://shopify/Location/922479430") {
location {
id
isActive
}
locationDeactivateUserErrors {
message
code
field
}
}
}`,
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: `mutation locationDeactivate {
locationDeactivate(locationId: "gid://shopify/Location/922479430") {
location {
id
isActive
}
locationDeactivateUserErrors {
message
code
field
}
}
}`,
});
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 locationDeactivate {
locationDeactivate(locationId: "gid://shopify/Location/922479430") {
location {
id
isActive
}
locationDeactivateUserErrors {
message
code
field
}
}
}
QUERY
response = client.query(query: query)
Response
JSON{
"locationDeactivate": {
"location": {
"id": "gid://shopify/Location/922479430",
"isActive": true
},
"locationDeactivateUserErrors": [
{
"message": "Location could not be deactivated without specifying where to relocate inventory stocked at the location.",
"code": "HAS_ACTIVE_INVENTORY_ERROR",
"field": [
"locationId"
]
}
]
}
}