location Editmutation
mutation
2024-01
Requires write
access scope or write
access scope. Also: write
: access scope is required to modify merchant-managed locations. write
: 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
The ID of a location to edit.
The updated properties for the location.
Was this section helpful?
LocationEditPayload returns
The location that was edited.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Examples
Hide code
DescriptionCopy
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-01/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/1069228945", "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/1069228945", "value": "Open from 7am to 10pm" } ] }, "ownerId": "gid://shopify/Location/346779380" }, }, ); 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 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/1069228945", "value"=>"Open from 7am to 10pm"}] }, "ownerId": "gid://shopify/Location/346779380" } response = client.query(query: query, variables: variables)
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/1069228945", "value": "Open from 7am to 10pm" } ] }, "ownerId": "gid://shopify/Location/346779380" }, }, });
use Shopify\Clients\Graphql; $client = new Graphql("your-development-store.myshopify.com", $accessToken); $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/1069228945", "value"=>"Open from 7am to 10pm"}], ], "ownerId" => "gid://shopify/Location/346779380", ]; $response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{ "input": { "metafields": [ { "namespace": "my_field", "key": "delivery_type", "type": "single_line_text_field", "value": "local" }, { "id": "gid://shopify/Metafield/1069228945", "value": "Open from 7am to 10pm" } ] }, "ownerId": "gid://shopify/Location/346779380" }
Hide code
Response
JSON
{ "locationEdit": { "location": { "id": "gid://shopify/Location/346779380", "metafields": { "edges": [ { "node": { "id": "gid://shopify/Metafield/1069228945", "namespace": "global", "key": "store_hours", "value": "Open from 7am to 10pm" } }, { "node": { "id": "gid://shopify/Metafield/1069228946", "namespace": "my_field", "key": "delivery_type", "value": "local" } } ] } }, "userErrors": [] } }