Automattic\WooCommerce\Blocks\Utils
CartCheckoutUtils::is_checkout_block_default
Checks if the default checkout page is using the Checkout block.
Method of the class: CartCheckoutUtils{}
No Hooks.
Returns
true|false. true if the WC checkout page is using the Checkout block.
Usage
$result = CartCheckoutUtils::is_checkout_block_default();
CartCheckoutUtils::is_checkout_block_default() CartCheckoutUtils::is checkout block default code WC 10.5.0
public static function is_checkout_block_default() {
if ( wp_is_block_theme() ) {
// Ignore the pages and check the templates.
$templates_from_db = BlockTemplateUtils::get_block_templates_from_db( array( 'checkout' ), 'wp_template' );
foreach ( $templates_from_db as $template ) {
if ( has_block( 'woocommerce/checkout', $template->content ) ) {
return true;
}
}
}
$checkout_page_id = wc_get_page_id( 'checkout' );
return $checkout_page_id && has_block( 'woocommerce/checkout', $checkout_page_id );
}