locationEdit
Requires access scope or
access scope. Also:
: access scope is required to modify merchant-managed locations.
: apps can edit the locations associated with their fulfillment services if they have this scope. Only the app that created the fulfillment service can edit its associated location.
Edits an existing location.
As of the 2023-10 API version, apps can change the name and address of their fulfillment service locations.
Arguments
- •ID!required
The ID of a location to edit.
- Anchor to inputinput•Location
Edit requiredInput! The updated properties for the location.
Anchor to LocationEditPayload returnsLocationEditPayload returns
- Anchor to locationlocation•
The location that was edited.
- Anchor to userErrorsuser•
Errors [LocationEdit non-nullUser Error!]! The list of errors that occurred from executing the mutation.
- Create a new metafield and update another on an existing location
- Edit a location and return the location ID
- locationEdit reference
Examples
mutation updateLocationMetafields($input: LocationEditInput!, $ownerId: ID!) {
locationEdit(input: $input, id: $ownerId) {
location {
id
metafields(first: 3) {
edges {
node {
id
namespace
key
value
}
}
}
}
userErrors {
message
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 updateLocationMetafields($input: LocationEditInput!, $ownerId: ID!) { locationEdit(input: $input, id: $ownerId) { location { id metafields(first: 3) { edges { node { id namespace key value } } } } userErrors { message field } } }",
"variables": {
"input": {
"metafields": [
{
"namespace": "my_field",
"key": "delivery_type",
"type": "single_line_text_field",
"value": "local"
},
{
"id": "gid://shopify/Metafield/1069229306",
"value": "Open from 7am to 10pm"
}
]
},
"ownerId": "gid://shopify/Location/346779380"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation updateLocationMetafields($input: LocationEditInput!, $ownerId: ID!) {
locationEdit(input: $input, id: $ownerId) {
location {
id
metafields(first: 3) {
edges {
node {
id
namespace
key
value
}
}
}
}
userErrors {
message
field
}
}
}`,
{
variables: {
"input": {
"metafields": [
{
"namespace": "my_field",
"key": "delivery_type",
"type": "single_line_text_field",
"value": "local"
},
{
"id": "gid://shopify/Metafield/1069229306",
"value": "Open from 7am to 10pm"
}
]
},
"ownerId": "gid://shopify/Location/346779380"
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation updateLocationMetafields($input: LocationEditInput!, $ownerId: ID!) {
locationEdit(input: $input, id: $ownerId) {
location {
id
metafields(first: 3) {
edges {
node {
id
namespace
key
value
}
}
}
}
userErrors {
message
field
}
}
}`,
"variables": {
"input": {
"metafields": [
{
"namespace": "my_field",
"key": "delivery_type",
"type": "single_line_text_field",
"value": "local"
},
{
"id": "gid://shopify/Metafield/1069229306",
"value": "Open from 7am to 10pm"
}
]
},
"ownerId": "gid://shopify/Location/346779380"
},
},
});
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 updateLocationMetafields($input: LocationEditInput!, $ownerId: ID!) {
locationEdit(input: $input, id: $ownerId) {
location {
id
metafields(first: 3) {
edges {
node {
id
namespace
key
value
}
}
}
}
userErrors {
message
field
}
}
}
QUERY
variables = {
"input": {
"metafields": [{"namespace"=>"my_field", "key"=>"delivery_type", "type"=>"single_line_text_field", "value"=>"local"}, {"id"=>"gid://shopify/Metafield/1069229306", "value"=>"Open from 7am to 10pm"}]
},
"ownerId": "gid://shopify/Location/346779380"
}
response = client.query(query: query, variables: variables)