Automattic\WooCommerce\Blocks\Utils

CartCheckoutUtils::is_cart_block_default()public staticWC 1.0

Checks if the default cart page is using the Cart block.

Method of the class: CartCheckoutUtils{}

No Hooks.

Return

true|false. true if the WC cart page is using the Cart block.

Usage

$result = CartCheckoutUtils::is_cart_block_default();

CartCheckoutUtils::is_cart_block_default() code WC 9.4.2

public static function is_cart_block_default() {
	if ( wc_current_theme_is_fse_theme() ) {
		// Ignore the pages and check the templates.
		$templates_from_db = BlockTemplateUtils::get_block_templates_from_db( array( 'cart' ), 'wp_template' );
		foreach ( $templates_from_db as $template ) {
			if ( has_block( 'woocommerce/cart', $template->content ) ) {
				return true;
			}
		}
	}
	$cart_page_id = wc_get_page_id( 'cart' );
	return $cart_page_id && has_block( 'woocommerce/cart', $cart_page_id );
}