Automattic\WooCommerce\Blocks\BlockTypes

AddToCartForm::add_to_cart_message_html_filter()publicWC 1.0

Filter the add to cart message to prevent the Notice from being displayed when the Add to Cart form is a descendent of a Single Product block and the Add to Cart button is clicked.

Метод класса: AddToCartForm{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$AddToCartForm = new AddToCartForm();
$AddToCartForm->add_to_cart_message_html_filter( $message );
$message(строка) (обязательный)
Message to be displayed when product is added to the cart.

Код AddToCartForm::add_to_cart_message_html_filter() WC 9.4.2

public function add_to_cart_message_html_filter( $message ) {
	// phpcs:ignore
	if ( isset( $_POST['is-descendent-of-single-product-block'] ) && 'true' === $_POST['is-descendent-of-single-product-block'] ) {
		return false;
	}
	return $message;
}