I’m trying to remove a WordPress action that’s been declared by Woocommerce Subscriptions in the following way:

class WC_Subscriptions_Synchroniser {

  public static function init() {

    add_action( 'woocommerce_single_product_summary', __CLASS__ . '::products_first_payment_date', 31 );
  }

  add_action( 'init', 'WC_Subscriptions_Synchroniser::init' );

}

The codex has a couple of examples for remove actions that have been declared within a class:
https://codex.wordpress.org/Function_Reference/remove_action

Which I’ve adapted & combined in the following way without success:

$my_class = new WC_Subscriptions_Synchroniser;
function remove_my_class_action(){

  global $my_class;
  remove_action( 'woocommerce_single_product_summary', array( $my_class, 'products_first_payment_date' ), 40 );
  remove_action( 'woocommerce_single_product_summary', array( 'WC_Subscriptions_Synchroniser', 'products_first_payment_date' ), 40 );

}
add_action( 'woocommerce_single_product_summary', 'remove_my_class_action', 40 );

I’ve also tried hooking the remove_my_class_action action with init but that doesn’t work either.

Help please!

Read more here: How to remove_action that’s been added via a class that’s hooked into WordPress?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: