I have an API endpoint which receives data from shopify. This contains information about return items for a particular order.
I can have multiple line-items under each order. I need to update the status of these line items based on the data I get from shopify return webhooks. The response looks like below:
"return_line_items": [
{
"id": 1234567890,
"admin_graphql_api_id": "gid://shopify/ReturnLineItem/1234567890",
"quantity": 1,
"return_reason": "size_too_large",
"return_reason_note": "",
"customer_note": null,
"fulfillment_line_item": {
"id": 1234567890,
"admin_graphql_api_id": "gid://shopify/FulfillmentLineItem/1234567890",
"line_item": {
"id": 1234567890,
"admin_graphql_api_id": "gid://shopify/LineItem/1234567890"
}
},
"unit_price": null,
"type": "ReturnLineItem",
"restocking_fee": null
},
{
"id": 1234567890,
"admin_graphql_api_id": "gid://shopify/ReturnLineItem/1234567890",
"quantity": 1,
"return_reason": "size_too_large",
"return_reason_note": "",
"customer_note": null,
"fulfillment_line_item": {
"id": 1234567890,
"admin_graphql_api_id": "gid://shopify/FulfillmentLineItem/1234567890",
"line_item": {
"id": 1234567890,
"admin_graphql_api_id": "gid://shopify/LineItem/1234567890"
}
},
"unit_price": null,
"type": "ReturnLineItem",
"restocking_fee": null
}
]
There are 2 items in return_line_items array. I have a table which has return_data which also has fulfillment_line_item.id (I can use this to identify the record). So when I receive this endpoint, I need to update all the records in return_data table with the new return status. How can I do this?