Order API: Set customer language / locale for notifications

Solved

Order API: Set customer language / locale for notifications

fhelger
Visitor
2 0 5

Hi,

 

how can we set the language for email and sms notifications when creating orders through the Shopify Rest API?

 

The customer_locale seems to be read-only according to the API reference (if that is even the right parameter for it).

 

Best regards,

Felix

Accepted Solution (1)

JamesG
Shopify Staff
42 10 11

This is an accepted solution.

Hi @fhelger 


You are correct that the REST Order.customer_locale field is read_only.

 

I can add a feature request for the REST API, but for now you could also try using the customerCreate or customerUpdate mutations to set the correct locale, then creating/ completing draft orders for the customer using the GraphQL Admin API to send notifications in the desired language as a workaround.

 

Cheers,

JamesG | API Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 8 (8)

geraldo2
Shopify Partner
2 0 1

I'm having the same issue here...

NielsLange
Visitor
2 0 1

I would love to here an answer on this. 
@Shopify can you please have a look at it. Thanks

JamesG
Shopify Staff
42 10 11

This is an accepted solution.

Hi @fhelger 


You are correct that the REST Order.customer_locale field is read_only.

 

I can add a feature request for the REST API, but for now you could also try using the customerCreate or customerUpdate mutations to set the correct locale, then creating/ completing draft orders for the customer using the GraphQL Admin API to send notifications in the desired language as a workaround.

 

Cheers,

JamesG | API Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

ShubhamDhage
Visitor
1 0 0

this did not worked for me, I tried with  customerUpdate mutation and I get a failed message saying --> Error: InputObject 'CustomerInput' doesn't accept argument 'languageCode'.

 

Please help if there is a solution.

ShopifyDevSup
Shopify Staff
1451 238 497

Hi @ShubhamDhage 👋


The notification language is determined by the `Customer.locale` attribute, formatted as an ISO code. The following is an example customerUpdate mutation and variables:

 

mutation ($input: CustomerInput!) {
    customerUpdate(input: $input) {
        customer {
            locale
        }
    }
}
{
    "input": {
        "id": "gid://shopify/Customer/5790884724854",
        "locale": "fr"
    }
}


The list of locales can be queried with the below:

{
    availableLocales {
        name
        isoCode
    }
}


Hope that helps!

 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

cemino
Shopify Partner
13 0 11

Is there any news regarding this feature for StorefrontAPI? We have a similar use case where we have to set the locale when creating a customer through Storefront API.

thanks!

palacemusic
Shopify Partner
1 0 0

Having the same issue and didn't find a solution so far.

CarmineT
Shopify Partner
87 2 26

I am not sure how to send a PUT request with update object for the customer.

What I mean is which is the Language field in the customer object and how one can send an update object with correct information?

What I mean is:

I do have in my shop set the geolocalzation app that show to customer correct content to customer(Italian, Greek in one of those countries and English elsewhere).

The problem is that I see that every customer is saved with "English" as language no matter, because the shop default language is English(and should be).

I also set a Flow that attached a correct tag based indeed either on local or ending of email address(my only way to "discriminate" between customer location when sending emails for communication.

I would still "fix" the language assigned to customer, if italian, then italian, if greek then greek

 

So to sum up, how the object send via PUT API should look like?