在Woocommerce结帐页面上移动Amazon Button [英] Move Amazon Button on Woocommerce Checkout Page
问题描述
我需要在Woocommerce的结帐页面上移动Amazon Pay消息/按钮.我们正在使用 Woocommerce的Amazon Pay .
I need to move the Amazon Pay message/button on the checkout page in Woocommerce. We are using Amazon Pay by Woocommerce.
当我查看插件代码时,我确定在插件的/woocommerce-gateway-amazon-payments-advanced.php文件中,使用以下命令添加了消息/按钮:
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 );
如果我将"woocommerce_before_checkout_form"更改为"woocommerce_after_checkout_form",它将移动.我一直在努力找出如何从我的functions.php中插入插件.
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.
推荐答案
以下内容对我有用:
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
必须具有优先级11
,因为Amazon Pay插件会以优先级10
添加操作.
woocommerce_checkout_init
must be at priority 11
, because the Amazon Pay plugin adds the action at priority 10
.
使用wc_apa()
代替$this
,因为wc_apa()
返回WC_Amazon_Payments_Advanced
类的实例,从而允许您访问checkout_message
方法.
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.
这篇关于在Woocommerce结帐页面上移动Amazon Button的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!