Create a resource allowing to update multiple order items at once

Created on 2 September 2021, over 3 years ago
Updated 11 August 2023, over 1 year ago

Problem/Motivation

We need a new JSON API resource, allowing to update multiple order items at once (right now, we can only update one at the time).

The route should be /carts/{commerce_order}/items (method: PATCH).

The route should return the updated order, validate order items, allow quantity = 0.

If quantity = 0 is passed, the cart manager should remove the order item from the cart.

Having this endpoint would give us more flexibility and is certainly a performance improvement.

Note that the order item should be validated (I'm thinking about the "purchased_entity" and "quantity" fields).

📌 Task
Status

Needs work

Version

1.0

Component

Code

Created by

🇮🇱Israel jsacksick

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇱Israel jsacksick

    I know this is old, but was giving it a try and there's first of all no way to update attributes, and, the route declaration is wrong.

    _jsonapi_resource should use the right resource :).

          '_jsonapi_resource' => CartUpdateItemsResource::class,
    
Production build 0.71.5 2024