is_woocommerce() │ WC 1.0

Checks if the displayed page uses the WooCommerce template.

The "Cart", "Checkout", and other similar pages are regular pages with shortcodes, so the function will return false there.

The function checks the following conditions: is_shop(), is_product_taxonomy(), is_product(). If at least one of them returns true, then the function will return true.

Hooks from the function

Returns

bool.

Usage

if( is_woocommerce() ){
	// ...
}

Examples

#1 Display the custom block if it's a WooCommerce page

<?php
if ( is_woocommerce() ) {
	?>
	<div class="block-woocommerce">
		Some block content.
	</div>
	<?php
}

is_woocommerce() code WC 11.2.2

function is_woocommerce() {
	/**
	 * Filters whether the current request is being handled by a WooCommerce template.
	 *
	 * @since 2.1.0
	 *
	 * @param bool $is_woocommerce True on the shop archive, a product taxonomy archive or a single product.
	 */
	return apply_filters( 'is_woocommerce', is_shop() || is_product_taxonomy() || is_product() );
}