Add order duplicate-cart endpoint#327
Conversation
Fill the DuplicateOrderCartCommand gap: PUT /orders/{orderId}/cart-duplications
(scope order_write) to duplicate an order's cart. Returns the new cart id.
Related to PrestaShop/PrestaShop#39630
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
mattgoud
left a comment
There was a problem hiding this comment.
OrderNotFoundException => 404 is missing from exceptionToStatus. Only DuplicateOrderCartException => 422 is mapped, so a bad orderId currently surfaces as 422 rather than a clean 404. Order endpoints should map the not-found case to 404.
Also missing a not-found / invalid negative test.
- Add OrderNotFoundException => HTTP_NOT_FOUND to exceptionToStatus. A bad orderId used to surface as 422; it now returns 404 cleanly. - Add testDuplicateNotFoundOrderCart covering PUT /orders/99999/... => 404. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Thanks @mattgoud — addressed in the last push.
Ready for another look. |
|
The
|
Without the core guard, DuplicateOrderCartHandler feeds false into ContextStateManager::setCart(?Cart) and produces a TypeError (500) before the 404 mapping can fire. Re-enable once the core PR lands. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Good catch @mattgoud — confirmed, Opened a core PR to add the guard: PrestaShop/PrestaShop#42065 (throws In the meantime I marked |
DuplicateOrderCartCommandgap:PUT /orders/{orderId}/cart-duplications(scopeorder_write) to duplicate an order's cart. Returns the new cart id along with the sourceorderId.PUT /orders/{id}/cart-duplications(client grantedorder_write) returns{ orderId, cartId }with the new cart id. Covered byOrderCartDuplicationEndpointTest.