I found this useful from the woocommerceWooCommerce developer documentation.
You can simply call is_woocommerce_active()is_woocommerce_active()
function within your plugin file.
Example
if ( ! is_woocommerce_active() ) { add_action( 'admin_notices', 'WC_Subscriptions::woocommerce_inactive_notice' ); return; }
if ( ! is_woocommerce_active() )
{
add_action( 'admin_notices', 'WC_Subscriptions::woocommerce_inactive_notice' );
return;
}
is_woocommerce_active defined as below as per woo documentation `` /**
- Check if WooCommerce is activated */ if ( ! function_exists( 'is_woocommerce_activated' ) ) { function is_woocommerce_activated() { if ( class_exists( 'woocommerce' ) ) { return true; } else { return false; } } } ``
/**
* Check if WooCommerce is activated
*/
if ( ! function_exists( 'is_woocommerce_activated' ) ) {
function is_woocommerce_activated() {
if ( class_exists( 'woocommerce' ) ) { return true; } else { return false; }
}
}