Automattic\WooCommerce\Blocks\Utils

CartCheckoutUtils::is_cart_page()public staticWC 1.0

Returns true if:

  • The cart page is being viewed.
  • The page contains a cart block, cart shortcode or classic shortcode block with the cart attribute.

Метод класса: CartCheckoutUtils{}

Хуков нет.

Возвращает

true|false.

Использование

$result = CartCheckoutUtils::is_cart_page();

Код CartCheckoutUtils::is_cart_page() WC 9.8.5

public static function is_cart_page() {
	global $post;

	$page_id      = wc_get_page_id( 'cart' );
	$is_cart_page = $page_id && is_page( $page_id );

	if ( $is_cart_page ) {
		return true;
	}

	// Check page contents for block/shortcode.
	return is_a( $post, 'WP_Post' ) && ( wc_post_content_has_shortcode( 'woocommerce_cart' ) || self::has_block_variation( 'woocommerce/classic-shortcode', 'shortcode', 'cart', $post->post_content ) );
}