Closed
Description
Simulator.Screen.Recording.-.iPad.Air.11-inch.M2.-.2025-03-26.at.10.54.29.mp4
- Add 2 products
- Check out so the order would be created
- Come back
- Remove one of the producs
- Add one invalid coupon
- Check out
- Get error
- Come back
- Remove an invalid coupon (the Cart should contain only one product now)
- Continue
- API Fails with `"Order item ID provided is not associated with order.
Request:
"coupon_lines": [],
"line_items": [
{
"id": 7588,
"product_id": 22,
"quantity": 0,
"subtotal": "0",
"total": "0"
},
{
"id": 0,
"product_id": 22,
"quantity": 1
}
]
}
Response:
{
"code": "woocommerce_rest_invalid_item_id",
"data": {
"status": 400
},
"message": "Order item ID provided is not associated with the order."
}
Investigation
When we remove a product from the cart, we make a request to an API with an order item with quantity 0. When we do this, the API removes the order item from the Order and returns an updated Order.
When we remove a product from the cart AND add an invalid coupon, during the Checkout an API request fails without returning an Order. However, in the remote, order item gets deleted. When we repeat a request with removed coupon, our request still contains an order item with quantity 0. However, this item no longer exists on the backend and the request fails with Order item ID provided is not associated with the order.
.
Solution
We may need to create rather than update the order during Checkout.
Discussion p1742989043210589-slack-C070SJRA8DP