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
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation updateLocale($locale: String!, $shopLocale: ShopLocaleInput!) {6 shopLocaleUpdate(locale: $locale, shopLocale: $shopLocale) {7 userErrors {8 message9 field10 }11 shopLocale {12 name13 locale14 primary15 published16 }17 }18 }`,19 {20 variables: {21 "locale": "ko",22 "shopLocale": {23 "published": true24 }25 },26 },27);2829const data = await response.json();30
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-10/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
JSON1{2 "locale": "ko",3 "shopLocale": {4 "published": true5 }6}
Response
JSON1{2 "shopLocaleUpdate": {3 "userErrors": [],4 "shopLocale": {5 "name": "Korean",6 "locale": "ko",7 "primary": false,8 "published": true9 }10 }11}