Automattic\WooCommerce\StoreApi\Utilities
CartController::validate_cart_not_empty
When placing an order, validate that the cart is not empty.
Метод класса: CartController{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$CartController = new CartController(); $CartController->validate_cart_not_empty();
Код CartController::validate_cart_not_empty() CartController::validate cart not empty WC 10.3.4
public function validate_cart_not_empty() {
$cart_items = $this->get_cart_items();
if ( empty( $cart_items ) ) {
throw new InvalidCartException(
'woocommerce_cart_error',
// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Errors are converted to response objects later.
new WP_Error( 'woocommerce_rest_cart_empty', esc_html__( 'Cannot place an order, your cart is empty.', 'woocommerce' ), 400 ),
400
);
}
}