Feat: add Cart Endpoint#201
Conversation
… should be int, not null
|
Hello @axel-paillaud! This is your first pull request on ps_apiresources repository of the PrestaShop project. Thank you, and welcome to this Open Source community! |
📋 Summary of changesThis PR introduces a full Cart domain (11 resource classes + 1 integration test): create/get/delete a cart ( ⏱️ Estimated review time30–40 minutes — 11 resource classes, 19 endpoints, several cross-cutting convention issues, Core query result alignment that needs verification. 🎯 Scope
🧱 API Platform / CQRS architecture compliance🔴 Hard blocker — CI-enforced violation
🟠 Missing
|
|
Hello @axel-paillaud Thank you for contributing! Please find the AI review above, which should help you improve the pull request. |
| use Symfony\Component\HttpFoundation\Response; | ||
|
|
||
| /** | ||
| * @deprecated Since PrestaShop 9.0. Will be removed in the next major version. |
There was a problem hiding this comment.
Why are you implementing a deprecated endpoint? :D
|
@kpodemski Regarding the |
Hello @kpodemski, The first point : For the second point : I suspect this is an error. Other bulk actions don't implement it (e.g., BulkDeleteZones), and |
|
Confirmed: no localised fields in the Cart resources. Product names and carrier names come from existing domain objects and are not stored directly in the Cart resource properties. |
|
Cart.php — no CQRSQueryMapping for GetCartForOrderCreation; field alignment unverified CQRSQuery absent on CQRSCreate/CQRSPartialUpdate in most sub-resource classes |
|
Missing validationContext on ALL 7 CQRSPartialUpdate operations Our Cart sub-resources have no constraints with Other endpoints, such as |
|
CartProducts.php: uses 'Add' group instead of 'Create' fixed |
|
Multi-shop Shop context ([_context][shopId]/[_context][shopConstraint]) not forwarded to any CQRS command/query despite ?shopId=1 being required per PR description
|
|
Integration test testInvalidData only covers testCreateCartInvalidData; no validation tests for PATCH/sub-resource endpoints PATCH test methods do not assert response body/structure testAddProductToCart asserts 'customization' => null in product structure, but Cart.php $products OpenAPI context defines no customization key — mismatch to clarify |
|
@kpodemski I've just checked all the points raised by the AI, let me know if it's okay |
All endpoints require
Authorization: Bearer {token}and?shopId=1.POST/carts{"customerId": 1}GET/carts/{cartId}DELETE/carts/{cartId}GET/carts/{cartId}/viewGET/carts/last-empty/{customerId}POST/carts/{cartId}/products{"productId": 1, "quantity": 2, "combinationId": null, "customizationsByFieldIds": {}}POST/carts/{cartId}/products(with customization){"productId": 19, "quantity": 1, "combinationId": null, "customizationsByFieldIds": {"3": "My custom text"}}DELETE/carts/{cartId}/products/{productId}PATCH/carts/{cartId}/products/quantity{"productId": 1, "quantity": 3, "combinationId": null, "customizationId": null}PATCH/carts/{cartId}/products/price{"productId": 1, "combinationId": 0, "price": 19.99}POST/carts/{cartId}/cart-rules{"cartRuleId": 1}DELETE/carts/{cartId}/cart-rules{"cartRuleId": 1}POST/carts/{cartId}/customizations{"productId": 19, "customizationValuesByFieldIds": {"3": "My custom text"}}PATCH/carts/{cartId}/addresses{"deliveryAddressId": 2, "invoiceAddressId": 2}PATCH/carts/{cartId}/carrier{"carrierId": 2}PATCH/carts/{cartId}/currency{"currencyId": 1}PATCH/carts/{cartId}/language{"languageId": 1}PATCH/carts/{cartId}/delivery-settings{"allowFreeShipping": false, "gift": false, "recycledPackaging": false, "giftMessage": null}POST/carts/{cartId}/send-email(deprecated)DELETE/carts/bulk-delete{"cartIds": [2, 3]}This PR need #41364 to work properly, otherwise the customerId field is null.
This doesn't prevent the endpoint from functioning correctly, but it shouldn't be null.