WooCommerce – Call to undefined function is_woocommerce()

If you want to check one Plugin’s Function / Class etc. from another Plugin, then it’s best to use a hook like plugins_loaded.

Based on this, your Plugin CODE will look like:

<?php
/*
Plugin Name: YOUR PLUGIN NAME
*/

defined( 'ABSPATH' ) or exit;

add_action( 'plugins_loaded', 'plugin_prefix_woocommerce_check' );
    function plugin_prefix_woocommerce_check() {
    if( function_exists( 'is_woocommerce' ) ) { 
        add_action( "wp_footer", "wpse_woocommerce_exists" );
    }   
    else {
        add_action( "wp_footer", "wpse_woocommerce_doesnt_exist" );
    }   
}   

function wpse_woocommerce_exists() {
    echo "<h1>WooCommerce Exists!</h1>";
}   

function wpse_woocommerce_doesnt_exist() {
    echo "<h1>WooCommerce Doesn't Exists!</h1>";
}

Directly checking other plugin functions will often lead to error, since WordPress may not be done loading other plugins by the time your CODE executes. However, when WordPress is done, it’ll fire the plugins_loaded hook.

Check Plugin Development Guide for more information on how to develop a WordPress Plugin.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)