I am trying to create an order and send the email in certain language.
orderCreate
does not let to set the desired locale
.
I thought that I would be able to set setReceipt
in options
for orderCreate
to false
"options": {
"sendReceipt": false,
then set the customer locale to the needed locale and then send email notification. But I do not see any mutation or query to send notifications. Please, help.
That’s why I though that I would create a customer with a locale first and the create an order on this customer with sendReceipt: true
and it will send the email in correct language. But it just overwrites the locale for the customer.
Also, I do not understand what is written in the docs (orderUpdate - GraphQL Admin), Checke the order
tab.
Note
If a customer is provided, this field or `shipping_address` (which has precedence) will be set as the customer's default address. Additionally, if the provided customer is new or hasn't created an order yet then their name will be set to the first/last name from this address (if provided).
Note
If a customer is provided, and no email is provided, the customer's email will be set to this field.
Note
If a customer is provided, this field (which has precedence) or billing_address will be set as the customer's default address. Additionally, if the provided customer doesn't have a first or last name then it will be set to the first/last name from this address (if provided).
customerId
ID
deprecated
The customer to associate to the order. Use customer instead.
So which customer are they referring to? There is no field to put customer in.
Docs seem to be misleading.
Please, let me know how to send the notifications in the correct language from Admin API with GraphQL.
To reproduce the bug:
- Create a new customer.
mutation customerCreate($input: CustomerInput!) {
customerCreate(input: $input) {
customer {
id
firstName
lastName
email
locale
}
userErrors {
field
message
}
}
}
with variables:
{
"input": {
"email": "user@example.com",
"locale": "fi"
}
}
Response:
{
"data": {
"customerCreate": {
"customer": {
"id": "gid://shopify/Customer/1234567890123",
"firstName": null,
"lastName": null,
"email": "new@example.com",
**"locale": "fi"**
},
"userErrors": []
}
},
...
You can even try to check that it was set:
query customer {
customer(id: "gid://shopify/Customer/1234567890123") {
locale
}
}
Response:
{
"data": {
"customer": {
**"locale": "fi"**
}
},
...
- Create an order for the existing user
mutation orderCreate($order: OrderCreateOrderInput!, $options: OrderCreateOptionsInput) {
orderCreate(order: $order, options: $options) {
userErrors {
field
message
}
order {
id
displayFinancialStatus
customer {
email
firstName
lastName
id
locale
}
shippingAddress {
address1
address2
city
countryCodeV2
country
province
provinceCode
zip
name
}
sourceIdentifier
}
}
}
Variables:
{
"order": {
"email": "new@example.com",
"lineItems": [
{
"variantId": "gid://shopify/ProductVariant/09876543210987",
"quantity": 1
}
],
"shippingAddress": {
"firstName": "John",
"lastName": "Doe",
"address1": "123 Main St",
"address2": "Unit 5",
"city": "New York",
"provinceCode": "NY",
"countryCode": "US",
"zip": "10001"
},
"financialStatus": "PAID",
"sourceIdentifier": "123"
},
"options": {
"sendReceipt": true,
"inventoryBehaviour": "DECREMENT_OBEYING_POLICY",
"sendFulfillmentReceipt": true
}
}
Response:
{
"data": {
"orderCreate": {
"userErrors": [],
"order": {
"id": "gid://shopify/Order/6436073472338",
"displayFinancialStatus": "PAID",
"customer": {
"email": "new@example.com",
"firstName": "John",
"lastName": "Doe",
"id": "gid://shopify/Customer/1234567890123",
**"locale": "en"**
},
"shippingAddress": {
"address1": "123 Main St",
"address2": "Unit 5",
"city": "New York",
"countryCodeV2": "US",
"country": "United States",
"province": "New York",
"provinceCode": "NY",
"zip": "10001",
"name": "John Doe"
},
"sourceIdentifier": "123"
}
}
},
...
As you can see, the order creation on the same email gives you different locale. If you try to query customer again. You will get indeed that locale is changed.
As a result I am always getting the email sent in the English language.
How can I send it in other languages?