[Performance] - Remove unnecessary calculate_totals() call in CartCoupons DELETE handler#63404
Conversation
Testing GuidelinesHi @woocommerce/rubik, Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed. Reminder: PR reviewers are required to document testing performed. This includes:
|
📝 WalkthroughWalkthroughRemoves a redundant Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…pons DELETE handler (#63404) * remove unnecessary calculate_totals * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>
…pons DELETE handler (#63404) * remove unnecessary calculate_totals * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>
Submission Review Guidelines:
Changes proposed in this Pull Request:
DELETE /wc/store/v1/cart/couponscalled$cart->calculate_totals()after removing all coupons, but the result was never used, the endpoint immediately returns an empty[]response body with no cart totals.calculate_totals()call fromCartCoupons::get_route_delete_response().GET /cart) will trigger recalculation viaCartController::get_cart_for_response()as designed.AbstractCartRoute::cart_updated()documents this explicitly: "This does not trigger a recalculation of the cart, endpoints should have already done so before returning the cart response."(For Bug Fixes) Bug introduced in PR # .
Screenshots or screen recordings:
N/A — logic change, no visual output.
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
SAVE10).POST /wc/store/v1/cart/couponswith body{"code": "SAVE10"}.GET /wc/store/v1/cartand note the discounted totals, confirmSAVE10appears in the coupon list.DELETE /wc/store/v1/cart/couponsand confirm the response is200 [].GET /wc/store/v1/cartagain and confirm the coupon list is empty and totals reflect full price with no discount.Testing that has already taken place:
Milestone
Changelog entry
Changelog Entry Details
Significance
Type
Message
Remove unnecessary
calculate_totals()call fromDELETE /wc/store/v1/cart/coupons. The result was never used since the endpoint returns an empty response body.Changelog Entry Comment
Comment