Store API: Ensure Store API recalculates cart totals prior to running validation hooks (#49455)
* Recalc totals on checkout route before validation * changelog
This commit is contained in:
parent
a9de74df6f
commit
b462cd58bc
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Ensure the Store API recalculates cart totals prior to running validation hooks.
|
|
@ -188,6 +188,12 @@ class Checkout extends AbstractCartRoute {
|
|||
* @return \WP_REST_Response
|
||||
*/
|
||||
protected function get_route_post_response( \WP_REST_Request $request ) {
|
||||
/**
|
||||
* Before triggering validation, ensure totals are current and in turn, things such as shipping costs are present.
|
||||
* This is so plugins that validate other cart data (e.g. conditional shipping and payments) can access this data.
|
||||
*/
|
||||
$this->cart_controller->calculate_totals();
|
||||
|
||||
/**
|
||||
* Validate items etc are allowed in the order before the order is processed. This will fix violations and tell
|
||||
* the customer.
|
||||
|
|
Loading…
Reference in New Issue