is_woocommerce()
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
true|false.
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() is woocommerce code WC 10.5.0
function is_woocommerce() {
return apply_filters( 'is_woocommerce', is_shop() || is_product_taxonomy() || is_product() );
}