Storefront Api Cart Mutations don't respect language code sent in @inContext

Hey @Tiago_Lima :waving_hand: . Thanks very much for the patience on this. I was able to speak with our product team for you and this documentation should help with explaining expected behaviour here:

Per the docs:

The buyer and country arguments for @inContext are ignored for cart queries. In order to get a contextualized cart, follow Step 4: Set the Buyer Identity on Cart to explicitly set the buyer identity with cartBuyerIdentityUpdate or during cartCreate. Other arguments on the @inContext directive (language) will still work as expected for cart queries.

From what I can tell, the behaviour you’re seeing does align with this. That said, we are in the process of making our documentation more clear for inContext directives specifically, so please let me know if I can share anything with the team or clarify anything and I’d be happy to set up a feature request for you. :slight_smile:

Hey @Alan_G. Thanks for the response!

However, even with that description, the behavior does not seem correct, if you look at the mutation with the Request ID: d3da891d-e292-4e66-8784-836b8f402755-1754931153 that I posted, you can see that the buyer identity is present and it has the country PT, I also ask for country PT with language PT_PT, so the buyer identity country matches the inContext country, and the buyer Identity has no way to set a language, so it should use the language I ask.

Even in the docs segment you placed it says “…Other arguments on the @inContext directive (language) will still work as expected for cart queries.“ which is not the case, the language tag is ignored.

Hey @Tiago_Lima - thanks for clarifying. I’ll reach out to some folks internally to confirm expected behaviour and loop back with you again here once I have more info to share. Appreciate you following up on this!

Hey again, Tiago, just following up here. I was able to work with our product team on this a bit today, and just to help us narrow down the issue, could you confirm whether the only unexpected/untranslated value is extensions.context.language in the mutation response (where it says EN), or are any translatable cart fields (e.g., product titles, option names) also coming back in EN? Just wanted to see if you are also seeing fields not being localized correctly.

Hey @Alan_G . Both extensions.context.language and the values in the cart object are not correct.

You can see in the last Mutation and Query that the products name are not equal.

Some of the fields:
The title field in cartLinesUpdate.cart.lines.nodes.*.merchandise.product.title
The optionValues in cartLinesUpdate.cart.lines.nodes. * *.*merchandise.product.options. *
the selected options in cartLinesUpdates.cart.lines.nodes. * . merchandise.product.selectedOptions

I believe other fields like metafields, images and so might not be translated as well, you can see query values for the expected translated fields.

I believe the language tag is simply ignored everywhere in the mutation.

Thanks @Tiago_Lima, appreciate you confirming that. I’ll keep you updated on this and loop back once I have next steps.

Hey @Tiago_Lima, following up here :waving_hand: - I’m still working on this for you and spoke with some of our developers today. Could you try the query below on an example cart where you’re seeing the behaviour and share the response/request ID if the issue persists?

query Cart($id: ID!) @inContext(country: country-here, language: PT_BR) {
  localization {
    availableLanguages {
      name
      endonymName
      isoCode
    }
  }
  
  cart(id: $id) {
    ...Cart
  }
}

fragment Cart on Cart {
  # Fragment defined here as needed
}

Hey @Alan_G here is simplified request along with request ids, queries and response payloads.

fragments
fragment BaseCart on Cart {
    id,
    buyerIdentity {
        countryCode,
        email,
        phone,
        customer {
            id,
            email
        }
    },
    lines(first: 250) {
        nodes {
            merchandise {
                ...ProductVariantWithProductSimplifiedMetaFields
            },
            quantity,
        }
    }
}

fragment ProductVariantWithProductSimplifiedMetaFields on ProductVariant {
    id,
    title,
    product {
        title,
        options {
            name,
            optionValues {
                id,
                name,
                swatch {
                    color,
                    image {
                        alt,
                        id
                    }
                }
            }
        }
    },
    selectedOptions {
        value,
        name,
    },
}

Mutation RequestID: 35b4490b-a66a-4aaf-b3b3-195f9bc8f711-1757677127

Mutation
mutation AddCartLineItems(
    $cartID: ID!,
    $lineItems: [CartLineInput!]!,
) @inContext(country: PT, language: PT_PT) {
    cartLinesAdd(
        cartId: $cartID,
        lines: $lineItems
    ) {
        userErrors {
            field,
            message
        },
        cart {
            ...BaseCart
        }
    }
}

Query RequestID: f727c98d-cadc-4ca0-a7ee-a9b44efed90c-1757677410

Query
query GetCart(
    $cartID: ID!,
) @inContext(country: PT, language: PT_PT) {
   cart(id: $cartID) {
            ...BaseCart
        }
}
Mutation Response
{
    "data": {
        "cartLinesAdd": {
            "userErrors": [],
            "cart": {
                "id": "gid://shopify/Cart/hWN2tAnYGbmBNS1xPKrwnDO7?key=30018961ec216917d2f352e31e7a9555",
                "buyerIdentity": {
                    "countryCode": "PT",
                    "email": null,
                    "phone": null,
                    "customer": null
                },
                "lines": {
                    "nodes": [
                        {
                            "merchandise": {
                                "id": "gid://shopify/ProductVariant/50550857761095",
                                "title": "3-4 Years",
                                "product": {
                                    "title": "Cotton Sweatshirt with Colour Block for Girls 'Minnie', Multicolour",
                                    "options": [
                                        {
                                            "name": "Size",
                                            "optionValues": [
                                                {
                                                    "id": "gid://shopify/ProductOptionValue/4294522405191",
                                                    "name": "3-4 Years",
                                                    "swatch": null
                                                },
                                                {
                                                    "id": "gid://shopify/ProductOptionValue/4294522437959",
                                                    "name": "4-5 Years",
                                                    "swatch": null
                                                },
                                                {
                                                    "id": "gid://shopify/ProductOptionValue/4294522470727",
                                                    "name": "5-6 Years",
                                                    "swatch": null
                                                },
                                                {
                                                    "id": "gid://shopify/ProductOptionValue/4294522503495",
                                                    "name": "6-7 Years",
                                                    "swatch": null
                                                },
                                                {
                                                    "id": "gid://shopify/ProductOptionValue/4294522536263",
                                                    "name": "7-8 Years",
                                                    "swatch": null
                                                },
                                                {
                                                    "id": "gid://shopify/ProductOptionValue/4294522569031",
                                                    "name": "8-9 Years",
                                                    "swatch": null
                                                },
                                                {
                                                    "id": "gid://shopify/ProductOptionValue/4294522601799",
                                                    "name": "9-10 Years",
                                                    "swatch": null
                                                },
                                                {
                                                    "id": "gid://shopify/ProductOptionValue/4294522634567",
                                                    "name": "11-12 Years",
                                                    "swatch": null
                                                }
                                            ]
                                        }
                                    ]
                                },
                                "selectedOptions": [
                                    {
                                        "value": "3-4 Years",
                                        "name": "Size"
                                    }
                                ]
                            },
                            "quantity": 3
                        }
                    ]
                }
            }
        }
    },
    "extensions": {
        "context": {
            "country": "PT",
            "language": "EN"
        },
        "cost": {
            "requestedQueryCost": 103
        }
    }
}
Query Response
{
    "data": {
        "cart": {
            "id": "gid://shopify/Cart/hWN2tAnYGbmBNS1xPKrwnDO7?key=30018961ec216917d2f352e31e7a9555",
            "buyerIdentity": {
                "countryCode": "PT",
                "email": null,
                "phone": null,
                "customer": null
            },
            "lines": {
                "nodes": [
                    {
                        "merchandise": {
                            "id": "gid://shopify/ProductVariant/50550857761095",
                            "title": "3-4 Anos",
                            "product": {
                                "title": "Sweat de Algodão com Colorblock para Menina 'Minnie', Multicolor",
                                "options": [
                                    {
                                        "name": "Size",
                                        "optionValues": [
                                            {
                                                "id": "gid://shopify/ProductOptionValue/4294522405191",
                                                "name": "3-4 Anos",
                                                "swatch": null
                                            },
                                            {
                                                "id": "gid://shopify/ProductOptionValue/4294522437959",
                                                "name": "4-5 Anos",
                                                "swatch": null
                                            },
                                            {
                                                "id": "gid://shopify/ProductOptionValue/4294522470727",
                                                "name": "5-6 Anos",
                                                "swatch": null
                                            },
                                            {
                                                "id": "gid://shopify/ProductOptionValue/4294522503495",
                                                "name": "6-7 Anos",
                                                "swatch": null
                                            },
                                            {
                                                "id": "gid://shopify/ProductOptionValue/4294522536263",
                                                "name": "7-8 Anos",
                                                "swatch": null
                                            },
                                            {
                                                "id": "gid://shopify/ProductOptionValue/4294522569031",
                                                "name": "8-9 Anos",
                                                "swatch": null
                                            },
                                            {
                                                "id": "gid://shopify/ProductOptionValue/4294522601799",
                                                "name": "9-10 Anos",
                                                "swatch": null
                                            },
                                            {
                                                "id": "gid://shopify/ProductOptionValue/4294522634567",
                                                "name": "11-12 Anos",
                                                "swatch": null
                                            }
                                        ]
                                    }
                                ]
                            },
                            "selectedOptions": [
                                {
                                    "value": "3-4 Anos",
                                    "name": "Size"
                                }
                            ]
                        },
                        "quantity": 3
                    }
                ]
            }
        }
    },
    "extensions": {
        "context": {
            "country": "PT",
            "language": "PT_PT"
        },
        "cost": {
            "requestedQueryCost": 92
        }
    }
}

As you can see in the payload, the query response answer with the correct language tag and the correct products name, while the mutation does not.
As you can see, in both cases the country is PT and language PT_PT and buyer identity country is also PT. However the mutation completely ignores the language tag while the query does not.

Thanks @Tiago_Lima - appreciate you sending all of these examples my way. I’ll loop back with some folks internally and investigate further. Really appreciate your patience as well.

Hey @Tiago_Lima - thanks again for your patience. I have a bit of an update to share. I still don’t have concrete information on when to expect a fix, but we have filed a bug tracking ticket internally on this for you and our developers are investigating this as a potential bug on our end now. I’ll keep you in the loop on this and reach out when I have more to share.

1 Like

Hey @Tiago_Lima - thanks very much for your patience on this. A possible fix has been pushed on our end, can you let me know if you’re still seeing this issue? If so, just let me know and I can take another look with you. Hope this helps :slight_smile:

Hey @Alan_G, the issue seems to be fixed on the API version 2025-07!

Thank you!

Awesome, thanks for following up @Tiago_Lima, glad to hear this is resolved!