Automattic\WooCommerce\Blocks\Utils
CartCheckoutUtils::is_cart_block_default
Checks if the default cart page is using the Cart block.
Method of the class: CartCheckoutUtils{}
No Hooks.
Returns
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() CartCheckoutUtils::is cart block default code WC 10.7.0
public static function is_cart_block_default() {
if ( wp_is_block_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 );
}