2
votes

I am developing a ecommerce theme. I have installed the WooCommerce PayPal Checkout Payment Gateway plugin for payment, and I want to change the location of this checkout button, I tried to remove_action display checkout button but it didn't work, How can I remove action in this case?

enter image description here enter image description here

Hook in plugin file:
plugins/woocommerce-gateway-paypal-express-checkout/includes/class-wc-gateway-ppec-with-spb.php

This is my code in functions.php file, it not works:

function remove_anon_filters( $name, $functionname, $priority ) {
    global $wp_filter;

    foreach ( $wp_filter[ $name ][ $priority ] as $key => $data ) {
        if ( stripos( $key, $functionname ) ) {
            remove_action( $name, $key, $priority );
        }
    }
}

add_action( 'plugins_loaded', 'demo_init', 999 );
function demo_init() {
    remove_anon_filters( 'woocommerce_review_order_after_submit', 'display_paypal_button', 10 );
}

// or.
add_action( 'init', 'remove_init', 999 );
function remove_init() {
    remove_action( 'woocommerce_review_order_after_submit', array( 'WC_Gateway_PPEC_With_SPB', 'display_paypal_button' ), 10 );
}

Any help is appreciated, thank you.

1
Are you able to solve this problem? I am also looking for solution.Owais Kiani
@OwaisKiani You can check answered of Howard E below and confirm? I can't check it yetttn_

1 Answers

2
votes

To remove a non-static method, you should instantiate the class, and remove the action in the wp_head https://developer.wordpress.org/reference/functions/remove_action/

Additionally, the remove_action should be the same priority as the add action, which in this case is not specified.

add_action( 'wp_head', 'remove_ppec_with_spb', 10);
function remove_ppec_with_spb() {
    $class = new WC_Gateway_PPEC_With_SPB;
    remove_action( 'woocommerce_review_order_after_submit', array( $class , 'display_paypal_button' ) );
}