问题
I need to move the Amazon Pay message/button on the checkout page in Woocommerce. We are using Amazon Pay by Woocommerce.
When I look at the plugin code I have determined that in the plugin's file /woocommerce-gateway-amazon-payments-advanced.php the message/button gets added using:
add_action( 'woocommerce_before_checkout_form', array( $this, 'checkout_message' ), 5 );
If I change 'woocommerce_before_checkout_form' to 'woocommerce_after_checkout_form' it moves. I have been struggling to figure out how to hook into the plugin from my functions.php.
回答1:
The following worked for me:
function move_amazon_pay() {
remove_action( 'woocommerce_before_checkout_form', array( wc_apa(), 'checkout_message' ), 5 );
add_action( 'woocommerce_after_checkout_form', array( wc_apa(), 'checkout_message' ), 5 );
}
add_action( 'woocommerce_checkout_init', 'move_amazon_pay', 11 );
woocommerce_checkout_init must be at priority 11, because the Amazon Pay plugin adds the action at priority 10.
Use wc_apa() instead of $this because wc_apa() returns an instance of the WC_Amazon_Payments_Advanced class, allowing you to access the checkout_message method.
来源:https://stackoverflow.com/questions/48715615/move-amazon-button-on-woocommerce-checkout-page