A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hello,
I'm trying to add a discount on an order line item and can't find a way to identify it with the LineItem ID I have when fetching the order through the REST API.
Order fetched from the REST API:
{'id': 1234,
'email': 'email@domain.com',
<...>
'line_items': [{'id': 5678,
'variant_id': 111,
<...>
'quantity': 1,
'admin_graphql_api_id': 'gid://shopify/LineItem/5678'},
{'id': 9000,
'variant_id': 555,
<...>
'quantity': 1,
'admin_graphql_api_id': 'gid://shopify/LineItem/9000'}],
<...>
}
When calling the mutation orderEditBegin, it returns CalculatedLineItems with IDs that I can't map to the LineItem IDs I have outside of the mutation.
Here's the orderEditBegin mutation:
mutation beginEdit($id: ID!){
orderEditBegin(id: $id){
calculatedOrder {
id
lineItems(first:30){
edges {
node {
id
quantity
variant {
sku
price
taxable
product {
productType
options {
id
name
position
values
}
}
}
customAttributes {
key
value
}
}
}
}
}
}
}
AFAIU the calculated order is just a temporary order between oderEditBegin and orderEditCommit. Hence, also the id's for the line items are temporary and only available during the transaction.
After orderEditCommit you get the finished order, for sure with the correct ids.