I am very surprised that I was able to create two orders with the same name within the same store even though Shopify’s documentation says the order names should be unique:
name
non-null
The unique identifier for the order that appears on the order page in the Shopify admin and the Order status page. For example, “#1001”, “EN1001”, or “1001-A”. This value isn’t unique across multiple stores. Use this field to identify orders in the Shopify admin and for order tracking.
This looks like a bug on Shopify because only order names are public to customers rather than the unique order number or shopify order id and when someone looks up the order by order name, it will return inconsistent order result when there are multiple orders with the same name. It will also break backends that rely on order name being unique within the same store:
Step to reproduce:
running this twice will create two shopify orders with the same name but different shopify order ids!
mutation orderCreate($order: OrderCreateOrderInput!, $options: OrderCreateOptionsInput) {
orderCreate(order: $order, options: $options) {
userErrors {
field
message
}
order {
id
totalTaxSet {
shopMoney {
amount
currencyCode
}
}
lineItems(first: 5) {
nodes {
variant {
id
}
id
title
quantity
taxLines {
title
rate
priceSet {
shopMoney {
amount
currencyCode
}
}
}
}
}
}
}
}
{
"order": {
"currency": "EUR",
"name":"test",
"lineItems": [
{
"title": "Big Brown Bear Boots",
"priceSet": {
"shopMoney": {
"amount": 74.99,
"currencyCode": "EUR"
}
},
"quantity": 3,
"taxLines": [
{
"priceSet": {
"shopMoney": {
"amount": 13.5,
"currencyCode": "EUR"
}
},
"rate": 0.06,
"title": "State tax"
}
]
}
],
"transactions": [
{
"kind": "SALE",
"status": "SUCCESS",
"amountSet": {
"shopMoney": {
"amount": 238.47,
"currencyCode": "EUR"
}
}
}
]
}
}