Automattic\WooCommerce\Blocks\Utils
CartCheckoutUtils::is_checkout_page
Returns true if:
- The checkout page is being viewed.
- The page contains a checkout block, checkout shortcode or classic shortcode block with the checkout attribute.
Method of the class: CartCheckoutUtils{}
No Hooks.
Returns
true|false
.
Usage
$result = CartCheckoutUtils::is_checkout_page();
CartCheckoutUtils::is_checkout_page() CartCheckoutUtils::is checkout page code WC 9.8.5
public static function is_checkout_page() { global $post; $page_id = wc_get_page_id( 'checkout' ); $is_checkout_page = $page_id && is_page( $page_id ); if ( $is_checkout_page ) { return true; } // Check page contents for block/shortcode. return is_a( $post, 'WP_Post' ) && ( wc_post_content_has_shortcode( 'woocommerce_checkout' ) || self::has_block_variation( 'woocommerce/classic-shortcode', 'shortcode', 'checkout', $post->post_content ) ); }