Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter jamiee89

    (@jamiee89)

    this is the code i have tried in my child theme function.php

    function init() {
    add_action( 'init', 'remove_stripe_pay_button', 10 );
    add_action( 'init', 'add_stripe_pay_button', 10 );
    
    function  remove_stripe_pay_button() {
    remove_action( 'woocommerce_checkout_before_customer_details', [ $this, 'display_payment_request_button_html' ], 1 );
    		remove_action( 'woocommerce_checkout_before_customer_details', [ $this, 'display_payment_request_button_separator_html' ], 2 );
      }
    function add_stripe_pay_button() {
        add_action( 'wc_payment_methods payment_methods methods' ,[ $this, 'display_payment_request_button_html' ], 1 );
         add_action( 'wc_payment_methods payment_methods methods' ,[ $this, 'display_payment_request_button_separator_html' ], 2 );
      }
    }

    I can’t seem to get it to work

    • This reply was modified 2 years, 7 months ago by jamiee89.
    Plugin Support 3 Sons Development – a11n

    (@3sonsdevelopment)

    Hey @jamiee89,

    Part of the trouble is these are added inside a PHP class. Outside of the class, you would have access to $this when removing and adding the actions.

    This post can show you how to remove actions added inside classes.

    https://zeropointdevelopment.com/how-to-remove-an-action-hook-or-filter-added-by-a-class-in-wordpress/

    If you still can’t quite get that working, then you could hire a freelance developer to make the changes for you. There are ones at Codeable who would be happy to assist.

    https://woocommerce.com/codeable/

    Cheers

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    We’ve not seen any activity on this thread for a while, so I’m marking it as resolved.

    Hopefully, you were able to find a solution, and the above resource shared by 3 Sons Development was helpful. If you have further questions, please feel free to open a new topic.

    Thanks.

    anonymized-14942572

    (@anonymized-14942572)

    Hi @rainfallnixfig , I don’t think you can consider the thread resolved.

    @jamiee89 you can modify the hooks starting at line 226 from the archive:

    \woocommerce-gateway-stripe\includes\payment-methods\class-wc-stripe-payment-request.php

    For example, change this hook

    add_action( 'woocommerce_checkout_before_customer_details', [ $this, 'display_payment_request_button_html' ], 1 );

    for:

    add_action( 'woocommerce_review_order_before_payment', [ $this, 'display_payment_request_button_html' ], 1 );

    Be aware of plugin updates.

    great its worked!!!
    but is there any way to use these hook in in functions.php anyway?
    coz if i update the plugin it will be gone…

    Thanks in advance…

    Hi @elias1435

    Have you tried the code snippets plugin way? It permits to add custom code in your site without touching the functions.php file.

    Is this what you are looking for? If I misunderstood something, let us know.

    More info: WordPress Plugin vs Functions.php file (Which is better?)

    Stumbled on this ticket as i was trying to find the hook for the button

    Ok I know this is old but for other you should NEVER modify the core code as suggested by @christiancabrero . You can use your functions.php of your child theme. So you can do like this @jamiee89 :

    
    remove_action( 'woocommerce_checkout_before_customer_details', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_html' ), 1 ); //removes the button
    remove_action( 'woocommerce_checkout_before_customer_details', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_separator_html' ), 2 ); // removes the separator under button
    
    
    add_action( 'woocommerce_review_order_before_payment', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_html' ), 1 ); // adds the button before payments 
    add_action( 'woocommerce_review_order_before_payment', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_separator_html' ), 2 ); // adds separator before payments after button
    Saif

    (@babylon1999)

    Hello @phyiel,

    You’re replying to an old thread that is already solved, I suggest you open a new one from here so your question is given more attention.

    Cheers!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘move apple/google pay button in checkout’ is closed to new replies.