remove_action not working for functions within a plugin

I’m trying to use remove_action to prevent a part of a plugin from running – don’t ask me why :-).

The function within the plugin is:

Read More
add_action( 'woocommerce_before_single_product_summary', array( $this, 'show_product_gallery' ), 30 );

and I’m trying to remove it by:

remove_action( 'woocommerce_before_single_product_summary', array( $this, 'show_product_gallery' ), 30 );

For some reason it isn’t doing the trick, although this usually works in WordPress / WooCommerce.

Can anyone shine a light on why this might be please? I have also tried hooking my function to other things e.g.

add_action( 'init', 'remove_it' );
function remove_it() {
remove_action( 'woocommerce_before_single_product_summary', array( $this, 'show_product_gallery' ), 30 );
}

(Plugin Code: https://codedump.io/share/axGWwMwAH0vn/1/linzs-hook-not-working)
Cheers,

Linz

Edited: This question is different to the previous one about remove_action not working, because that was related to the wrong priority – whereas this priority is correct at 30.

Related posts

1 comment

  1. You need to access the class variable globally. Please try this.

    add_action( 'wp', 'remove_it' );
    function remove_it() {
     global $WC_Product_Gallery_slider;
     remove_action( 'woocommerce_before_single_product_summary', array( $WC_Product_Gallery_slider, 'show_product_gallery' ), 30 );
    }
    

Comments are closed.