WooCommerce :: How to properly remove WC_Structured_Data::generate_website_data() hook







This is how you can remove hooks associated with instantiated object method. You have to find the variable that holds the new Object instance.

In this case the main WooCommerce object is accessible as `$GLOBALS['woocommerce']` and it has public property `$structured_data` which holds an instance of the WC_Structured_Data object.

Hence, to remove the hook in the question you can write this code:

remove_action( ‘woocommerce_before_main_content’, array( $GLOBALS['woocommerce']->structured_data, ‘generate_website_data’ ), 30 );