\/button>/i';
preg_match( $regex_pattern, $product, $input_matches );
if ( ! empty( $input_matches ) ) {
$product = preg_replace( $regex_pattern, $hidden_is_descendent_of_single_product_block_input . $input_matches[0], $product );
}
return $product;
}
/**
* 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.
*
* @param string $message Message to be displayed when product is added to the cart.
*/
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;
}
/**
* Hooks into the `woocommerce_add_to_cart_redirect` filter to prevent redirecting
* to another page when the block is inside the Single Product block and the Add to Cart button
* is clicked.
*
* @param string $url The URL to redirect to after the product is added to the cart.
* @return string The filtered redirect URL.
*/
public function add_to_cart_redirect_filter( $url ) {
// phpcs:ignore
if ( isset( $_POST['is-descendent-of-single-product-block'] ) && 'true' == $_POST['is-descendent-of-single-product-block'] ) {
if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) {
return wc_get_cart_url();
}
return wp_validate_redirect( wp_get_referer(), $url );
}
return $url;
}
/**
* Get the frontend script handle for this block type.
*
* @param string $key Data to get, or default to everything.
*/
protected function get_block_type_script( $key = null ) {
return null;
}
/**
* Get the frontend style handle for this block type.
*
* @return null
*/
protected function get_block_type_style() {
return array_merge( parent::get_block_type_style(), [ 'wc-blocks-packages-style' ] );
}
/**
* It isn't necessary register block assets because it is a server side block.
*/
protected function register_block_type_assets() {
return null;
}
}
Fatal error: Uncaught Error: Class "Automattic\WooCommerce\Blocks\BlockTypes\AddToCartForm" not found in /home/valigeria/public_html/wp-content/plugins/woocommerce/src/Blocks/BlockTypesController.php:106
Stack trace:
#0 /home/valigeria/public_html/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\Blocks\BlockTypesController->register_blocks('')
#1 /home/valigeria/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#2 /home/valigeria/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#3 /home/valigeria/public_html/wp-settings.php(695): do_action('init')
#4 /home/valigeria/public_html/wp-config.php(111): require_once('/home/valigeria...')
#5 /home/valigeria/public_html/wp-load.php(50): require_once('/home/valigeria...')
#6 /home/valigeria/public_html/wp-blog-header.php(13): require_once('/home/valigeria...')
#7 /home/valigeria/public_html/index.php(17): require('/home/valigeria...')
#8 {main}
thrown in /home/valigeria/public_html/wp-content/plugins/woocommerce/src/Blocks/BlockTypesController.php on line 106