Simplified CartApplyCoupon::get_post_route_response()

This commit is contained in:
Paulo Arromba 2024-03-06 14:57:48 +00:00
parent 35d96f007f
commit 43f185b59a
1 changed files with 2 additions and 5 deletions

View File

@ -60,13 +60,10 @@ class CartApplyCoupon extends AbstractCartRoute {
$coupon_code = wc_format_coupon_code( wp_unslash( $request['code'] ) );
try {
$this->cart_controller->apply_coupon( $coupon_code );
} catch ( \WC_REST_Exception $e ) {
throw new RouteException( $e->getErrorCode(), $e->getMessage(), $e->getCode() );
}
$this->cart_controller->apply_coupon( $coupon_code );
$cart = $this->cart_controller->get_cart_instance();
return rest_ensure_response( $this->schema->get_item_response( $cart ) );
}
}