Anchor to section titled 'undefined'

shopLocaleUpdate
mutation

Requires write_locales access scope.

Updates a locale for a shop.


ISO code of the locale to update.

Specifies the input fields for a shop locale.


Was this section helpful?

The locale that was updated.

The list of errors that occurred from executing the mutation.


Was this section helpful?

Examples

Hide code
DescriptionCopy
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-01/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();
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)
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
      }
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$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]);
Hide code
Input variables
Copy
{
  "locale": "ko",
  "shopLocale": {
    "published": true
  }
}
Hide code
Response
JSON
{
  "shopLocaleUpdate": {
    "userErrors": [],
    "shopLocale": {
      "name": "Korean",
      "locale": "ko",
      "primary": false,
      "published": true
    }
  }
}