Skip to content

Instantly share code, notes, and snippets.

@espiat
Forked from dougaitken/move_stripeprbutton.php
Created December 20, 2021 21:25
Show Gist options
  • Save espiat/1e70ed6a45691af6a9c36067c769736e to your computer and use it in GitHub Desktop.
Save espiat/1e70ed6a45691af6a9c36067c769736e to your computer and use it in GitHub Desktop.
Moving the WooCommerce Stripe Payment Request buttons below the add to cart button
/** Move Stripe Payment Request Button on product page **/
remove_action( 'woocommerce_after_add_to_cart_quantity', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_html' ), 1 );
remove_action( 'woocommerce_after_add_to_cart_quantity', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_separator_html' ), 2 );
add_action( 'woocommerce_after_add_to_cart_button', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_html' ), 2 );
add_action( 'woocommerce_after_add_to_cart_button', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_separator_html' ), 1 );
@espiat
Copy link
Author

espiat commented Dec 20, 2021

hi Figured it out with your above code. Sharing so other could also use it until a solution is rolled out for this known issue here -
woocommerce/woocommerce-gateway-stripe#832

The fix is to go to file
woocommerce-gateway-stripe/includes/payment-methods/class-wc-stripe-payment-request.php

and replace code
if ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ) {
add_action( 'woocommerce_after_add_to_cart_button', array( $this, 'display_payment_request_button_html' ), 1 );
add_action( 'woocommerce_after_add_to_cart_button', array( $this, 'display_payment_request_button_separator_html' ), 2 );
} else {
add_action( 'woocommerce_after_add_to_cart_quantity', array( $this, 'display_payment_request_button_html' ), 1 );
add_action( 'woocommerce_after_add_to_cart_quantity', array( $this, 'display_payment_request_button_separator_html' ), 2 );
}

with
add_action( 'woocommerce_after_add_to_cart_button', array( $this, 'display_payment_request_button_html' ), 2 );
add_action( 'woocommerce_after_add_to_cart_button', array( $this, 'display_payment_request_button_separator_html' ), 1 );

hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment