Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
api version: 2024-10
request url: https://xxx.myshopify.com/admin/api/2024-10/graphql.json
query:
mutation draftOrderCreate($input: DraftOrderInput!) { draftOrderCreate(input: $input) { draftOrder { id localizationExtensions(first:1) { edges { node { key value } } } } } }graphql variables:
{ "input": { "email": "test@example.com", "lineItems": { "variantId": "gid://shopify/ProductVariant/xxxxxx", "quantity": 1 }, "localizationExtensions": { "key": "TAX_CREDENTIAL_MX", "value": "test" } } }
{ "data": { "draftOrderCreate": { "draftOrder": { "id": "gid://shopify/DraftOrder/xxxxxxx", "localizationExtensions": { "edges": [] } } } }, "extensions": { "cost": { ... } } }I follow this doc to test the api. But it does not set localizationExtensions.
Hi @mckingho
The issue likely lies in the format of the localizationExtensions input. In your query, localizationExtensions is being sent as a single object, but Shopify's API expects it to be a list (array) of objects. This discrepancy may be why the localizationExtensions are not being set in the draft order.
According to the Shopify documentation on adding locally required order data, localizationExtensions should be provided as an array of objects.
Here’s the corrected GraphQL query and variables:
mutation draftOrderCreate($input: DraftOrderInput!) { draftOrderCreate(input: $input) { draftOrder { id localizationExtensions(first: 1) { edges { node { key value } } } } } }
{ "input": { "email": "test@example.com", "lineItems": [ { "variantId": "gid://shopify/ProductVariant/xxxxxx", "quantity": 1 } ], "localizationExtensions": [ { "key": "TAX_CREDENTIAL_MX", "value": "test" } ] } }
localizationExtensions as an Array: The localizationExtensions field should be a list ([]) of key-value objects, not a single object.
lineItems as an Array: Shopify requires lineItems to be an array of objects, even if there is only one line item.
Shopify GraphQL expects fields like localizationExtensions and lineItems to follow a specific structure. Using a single object where an array is required can result in the input being ignored, as in your case.
After correcting the input format, the localizationExtensions data should be properly processed and reflected in the response.
Retry the query with the corrected format. If the issue persists, verify that:
Your Shopify store has the relevant localization setup for the key you're adding (e.g., TAX_CREDENTIAL_MX).
You have the necessary permissions for using this field in the API.
If my reply is helpful, kindly click like and mark it as an accepted solution.
If you are happy with my help, you can help me buy a COFFEE
Thanks!
Thanks for answering. I have updated both lineItems and localizationExtensions to array format. It still does not work. lineItems is set but localizationExtensions is not set.
Here's my updated request.
query
mutation draftOrderCreate($input: DraftOrderInput!) {
draftOrderCreate(input: $input) {
draftOrder {
id
lineItems(first: 10) {
edges {
node {
id
}
}
}
localizationExtensions(first:1) {
edges {
node {
key
value
}
}
}
}
}
}
graphql variables
{
"input": {
"email": "test@example.com",
"lineItems": [{
"variantId": "gid://shopify/ProductVariant/xxxxx",
"quantity": 1
}],
"localizationExtensions": [{
"key": "TAX_CREDENTIAL_MX",
"value": "test"
}]
}
}
response
{
"data": {
"draftOrderCreate": {
"draftOrder": {
"id": "gid://shopify/DraftOrder/xxxx",
"lineItems": {
"edges": [
{
"node": {
"id": "gid://shopify/DraftOrderLineItem/xxxx"
}
}
]
},
"localizationExtensions": {
"edges": []
}
}
}
},
"extensions": {
"cost": {
...
}
}
}
The issue might be related to how the localizationExtensions feature is implemented or configured in your Shopify store. Let’s troubleshoot and resolve this:
Check Market Configuration:
Test Another Key-Value Pair:
{ "key": "TAX_CREDENTIAL_CA", "value": "test" }
Include Shipping/Billing Address:
"shippingAddress": { "address1": "123 Main St", "city": "Mexico City", "country": "MX", "zip": "12345" }
Contact Shopify Support:
Here’s a refined example that incorporates potential fixes:
{ "input": { "email": "test@example.com", "lineItems": [ { "variantId": "gid://shopify/ProductVariant/xxxxx", "quantity": 1 } ], "shippingAddress": { "address1": "123 Main St", "city": "Mexico City", "country": "MX", "zip": "12345" }, "localizationExtensions": [ { "key": "TAX_CREDENTIAL_MX", "value": "test" } ] } }
I tried draftOrderCreate and orderUpdate mutation with BR and MX data.
Data I use:
{
"input": {
...
"localizationExtensions": [{
"key": "TAX_CREDENTIAL_BR",
"value": "39053344705"
}]
}
}
{
"input": {
...
"localizationExtensions": [{
"key": "TAX_CREDENTIAL_MX",
"value": "HEGA820506M10"
}]
}
}
1. draftOrderCreate, both not set
{
"data": {
"draftOrderCreate": {
"draftOrder": {
...
"localizationExtensions": {
"edges": []
}
}
}
},
"extensions": {
"cost": {
...
}
}
}
2. updateOrder, TAX_CREDENTIAL_BR can be set correctly.
TAX_CREDENTIAL_MX is not set and returns invalid key error.
{
"data": {
"orderUpdate": {
"order": {
...
},
"userErrors": [
{
"message": "Localization extension: 'key' provided is invalid",
"field": [
"localizationExtensions",
"0",
"message"
]
}
]
}
},
"extensions": {
"cost": {
...
}
}
}
It seems like you are trying to use draftOrderCreate and orderUpdate mutations in a GraphQL API to add localization extensions for Brazilian and Mexican tax credentials. Here's a breakdown of your issue and suggestions on how to resolve it.
Invalid Key for Mexico:
Solution:
Schema Mismatch:
Solution:
Localization Extensions in draftOrderCreate:
Solution:
API Configuration and Permissions:
Test with different localization keys: Try replacing TAX_CREDENTIAL_MX with a known valid key like RFC_MX (for Mexico), as it might be the correct key for tax credentials in Mexico.
Check API documentation for localization keys to confirm if TAX_CREDENTIAL_MX is a valid key for localization extensions or if there is an alternate key like RFC_MX.
Check for API updates or restrictions: Some APIs have limitations or updates that might restrict or validate specific keys. Ensure the system supports both BR and MX credentials properly.
Validate during Draft Order Creation: If draftOrderCreate is not setting the localization extensions, check the API's handling of localization data at that stage. If needed, refer to the API’s official documentation for creating draft orders with custom localization extensions.
Test with simple data: Test the system by setting only one localization key (e.g., TAX_CREDENTIAL_BR for Brazil) in both draftOrderCreate and orderUpdate to check if the issue is specific to the combination of keys.
You can modify your request like this to test the new key:
{ "input": { "localizationExtensions": [{ "key": "RFC_MX", "value": "HEGA820506M10" }] } }
The core issue seems to be related to invalid key for Mexico (TAX_CREDENTIAL_MX). Double-check the API documentation to confirm the correct key, and consider using alternatives like RFC_MX for Mexico.
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025