Skip to content

[Woo POS] Coupons: Product Changes & Invalid Coupon in Order update request changes the remote Order despite API error #15426

Closed
@staskus

Description

@staskus
Simulator.Screen.Recording.-.iPad.Air.11-inch.M2.-.2025-03-26.at.10.54.29.mp4
  1. Add 2 products
  2. Check out so the order would be created
  3. Come back
  4. Remove one of the producs
  5. Add one invalid coupon
  6. Check out
  7. Get error
  8. Come back
  9. Remove an invalid coupon (the Cart should contain only one product now)
  10. Continue
  11. 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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions