Support » Plugin: WooCommerce Cart Stock Reducer » Check if Plugin is active

  • Resolved ddoddsr

    (@ddoddsr)


    I need to check if your plugin is active and enabled?

    How best to check when running from the theme.

    If the plugin is not active, I’ll count my own cart against the available stock.
    If the plugin is active I don’t want to count my cart twice.
    Also if your plugin is active i don’t need to run another function.
    yhanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author James Golovich

    (@jamesgol)

    If you just want to check if the plugin is installed you can use the WordPress functions for that.

    If you want to make sure it’s actually enabled then you can grab the object instance from WooCommerce integrations and check that way.

    I do want to test if it is enabled. WooCommerce integrations is new to me so I’ve not found how to grab the object instance .

    Plugin Author James Golovich

    (@jamesgol)

    You can call WC()->integrations->get_integrations() to get all of the integrations that are active

    I also wanted “Enabled” or not so I used
    add_action( ‘init’, function () {
    foreach ( WC()->integrations->get_integrations() as $integration) {
    if ( $integration->id == ‘woocommerce-cart-stock-reducer’ ) {
    $this->wc_cart_reducer_enabled = $integration->cart_stock_reducer ;
    }
    }
    });

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Check if Plugin is active’ is closed to new replies.