How to check if WooCommerce plugin is enabled?

Viewed 1041

I'm trying to check if woo commerce plugin is active then add some options to the option panel. but this code doesn't work right.

can anyone tell me what is wrong? thanks.

 if( class_exists( 'WooCommerce' )) {//add options}
1 Answers

Try the following instead:

if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
    // Yes, WooCommerce is enabled
} else {
    // WooCommerce is NOT enabled!
}
Related