Move Amazon Button on Woocommerce Checkout Page

不羁岁月 提交于 2019-12-21 21:46:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!