1. Documentation
  2. Codex
  3. Snippets
  4. Theming Snippets

Query whether WooCommerce is activated

This is a Developer level doc. If you are unfamiliar with code and resolving potential conflicts, select a WooExpert or Developer for assistance. We are unable to provide support for customizations under our  Support Policy.

If you’re building a theme which supports but doesn’t require WooCommerce, you may want to wrap WooCommerce functionality (think cart links etc) inside a conditional query. That way, if WooCommerce isn’t activated, the functionality is simply ignored instead of producing fatal errors.

* Check if WooCommerce is activated
if ( ! function_exists( 'is_woocommerce_activated' ) ) {
function is_woocommerce_activated() {
if ( class_exists( 'woocommerce' ) ) { return true; } else { return false; }

WooCommerce - the most customizable eCommerce platform for building your online business.

  • 30 day money back guarantee
  • Support teams across the world
  • Safe & Secure online payment