Automattic\WooCommerce\StoreApi\Utilities
CartController::throw_default_product_exception
Default exception thrown when an item cannot be added to the cart.
Метод класса: CartController{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->throw_default_product_exception( $product );
- $product(WC_Product) (обязательный)
- Product object associated with the cart item.
Код CartController::throw_default_product_exception() CartController::throw default product exception WC 11.0.1
protected function throw_default_product_exception( \WC_Product $product ) {
$product_name = $this->get_product_name( $product );
if ( empty( $product_name ) ) {
$message = __( 'This item is not available for purchase.', 'woocommerce' );
} else {
$message = sprintf(
/* translators: %s: product name */
__( '"%s" is not available for purchase.', 'woocommerce' ),
$product_name
);
}
throw new RouteException(
'woocommerce_rest_product_not_purchasable',
esc_html( $message ),
400
);
}