Anchor to shopLocaleUpdateshop
shopLocaleUpdate
mutation
Requires access scope.
Updates a locale for a shop.
Anchor to Arguments
Arguments
- Anchor to localelocale•String!required
ISO code of the locale to update.
- Anchor to shopLocaleshop•
Locale ShopLocale requiredInput! Specifies the input fields for a shop locale.
Was this section helpful?
Anchor to ShopLocaleUpdatePayload returnsShopLocaleUpdatePayload returns
- Anchor to shopLocaleshop•
Locale The locale that was updated.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Publish a locale
- Unpublish a locale
- shopLocaleUpdate reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation updateLocale($locale: String!, $shopLocale: ShopLocaleInput!) {
shopLocaleUpdate(locale: $locale, shopLocale: $shopLocale) {
userErrors {
message
field
}
shopLocale {
name
locale
primary
published
}
}
}`,
{
variables: {
"locale": "ko",
"shopLocale": {
"published": true
}
},
},
);
const data = await response.json();
mutation updateLocale($locale: String!, $shopLocale: ShopLocaleInput!) {
shopLocaleUpdate(locale: $locale, shopLocale: $shopLocale) {
userErrors {
message
field
}
shopLocale {
name
locale
primary
published
}
}
}
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 updateLocale($locale: String!, $shopLocale: ShopLocaleInput!) { shopLocaleUpdate(locale: $locale, shopLocale: $shopLocale) { userErrors { message field } shopLocale { name locale primary published } } }",
"variables": {
"locale": "ko",
"shopLocale": {
"published": true
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation updateLocale($locale: String!, $shopLocale: ShopLocaleInput!) {
shopLocaleUpdate(locale: $locale, shopLocale: $shopLocale) {
userErrors {
message
field
}
shopLocale {
name
locale
primary
published
}
}
}`,
{
variables: {
"locale": "ko",
"shopLocale": {
"published": true
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation updateLocale($locale: String!, $shopLocale: ShopLocaleInput!) {
shopLocaleUpdate(locale: $locale, shopLocale: $shopLocale) {
userErrors {
message
field
}
shopLocale {
name
locale
primary
published
}
}
}`,
"variables": {
"locale": "ko",
"shopLocale": {
"published": true
}
},
},
});
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 updateLocale($locale: String!, $shopLocale: ShopLocaleInput!) {
shopLocaleUpdate(locale: $locale, shopLocale: $shopLocale) {
userErrors {
message
field
}
shopLocale {
name
locale
primary
published
}
}
}
QUERY
variables = {
"locale": "ko",
"shopLocale": {
"published": true
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"locale": "ko",
"shopLocale": {
"published": true
}
}
Response
JSON{
"shopLocaleUpdate": {
"userErrors": [],
"shopLocale": {
"name": "Korean",
"locale": "ko",
"primary": false,
"published": true
}
}
}