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.

Method of the class: AddToCartForm{}

No Hooks.

Return

null. Nothing (null).

Usage

$AddToCartForm = new AddToCartForm();
$AddToCartForm->add_to_cart_message_html_filter( $message );
$message(string) (required)
Message to be displayed when product is added to the cart.

AddToCartForm::add_to_cart_message_html_filter() code 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;
}