Home > Mobile >  disabling the action function of a class in woocommerce subscriptions
disabling the action function of a class in woocommerce subscriptions

Time:08-24

i use the woocommerce subscriptions plugin, i have a class class WC_Subscriptions_Cart {}, inside the function class is the following :

/**
 * Display the recurring totals for items in the cart
 *
 * @since 2.0
 */
public static function display_recurring_totals() {

    if ( self::cart_contains_subscription() ) {

        // We only want shipping for recurring amounts, and they need to be calculated again here
        self::$calculation_type       = 'recurring_total';
        $carts_with_multiple_payments = 0;

        foreach ( WC()->cart->recurring_carts as $recurring_cart ) {
            // Cart contains more than one payment
            if ( 0 != $recurring_cart->next_payment_date ) {
                $carts_with_multiple_payments  ;
            }
        }

        if ( apply_filters( 'woocommerce_subscriptions_display_recurring_totals', $carts_with_multiple_payments >= 1 ) ) {
            wc_get_template(
                'checkout/recurring-totals.php',
                array(
                    'shipping_methods'             => array(),
                    'recurring_carts'              => WC()->cart->recurring_carts,
                    'carts_with_multiple_payments' => $carts_with_multiple_payments,
                ),
                '',
                WC_Subscriptions_Core_Plugin::instance()->get_subscriptions_core_directory( 'templates/' )
            );
        }

        self::$calculation_type = 'none';
    }
}

its action is as follows :

public static function init() {
    add_action( 'woocommerce_cart_totals_after_order_total', __CLASS__ . '::display_recurring_totals' );
}

i want to disable this action, my code is not working :

function remove_my_class_action(){
    remove_action( 'woocommerce_cart_totals_after_order_total', array( 'WC_Subscriptions_Cart', 'display_recurring_totals' ) );
} add_action( 'woocommerce_cart_totals_after_order_total', 'remove_my_class_action' );

how can i disable this action through the function.php file? i appreciate any reply from you.

CodePudding user response:

after repeated attempts, i got the answer :

remove_action( 'woocommerce_cart_totals_after_order_total', array( 'WC_Subscriptions_Cart', 'display_recurring_totals' ), 10 );
  • Related