Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translations for items #302

Open
RWAP opened this issue Aug 4, 2023 · 1 comment
Open

Translations for items #302

RWAP opened this issue Aug 4, 2023 · 1 comment

Comments

@RWAP
Copy link

RWAP commented Aug 4, 2023

Shopify now appears to support translatable content for products, but I could not see that this is implemented in the code (or how to access it):

https://shopify.dev/docs/api/admin-graphql/2023-07/queries/translatableResource#section-examples

@whobutsb
Copy link
Contributor

whobutsb commented Sep 29, 2023

I ran in to this issue as well. You need to use the Storefront GraphQL API in order to retrieve the translations. I actually just wrote a PR #308 that allows you to use this library to make requests to the storefront api.

Here is how you would use the PR to get a product translations for french Canadian:

$shopify = \PHPShopify\ShopifySDK::config([
    'AccessToken' => 'SHOPIFY_ADMIN_TOKEN',
    'ShopUrl' => 'my-store.myshopify.com',
    'StoreFrontAccessToken' => 'STOREFRONT_ACCESS_TOKEN'
]);

$query = <<<GQL
    query getProductById(\$id: ID!) @inContext(country: CA, language: FR) {
        product(id: \$id) {
            id
            title
            handle
            productType
            tags
            descriptionHtml
            options {
                id
                name
                values
            }
        }
    }
GQL;
// product global id - 'gid://shopify/Product/123456789'
$variables = [
    'id' => $productGID
];

$data = $shopify->GraphQL->storefront($query, null, null, $variables);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants