在 Woocommerce 3 中的我的帐户订单视图页面上显示付款说明
Display payment instructions on my account order view pages in Woocommerce 3
实际上,付款说明显示在“已收到订单”页面上:
我想要的是在我的帐户 > 订单视图页面中也显示此付款说明。
像这样:
我的问题:如何让付款指令出现在我的账户 > 订单查看页面?
我知道它会发送到客户邮箱,但如果他们懒得打开电子邮件,他们可以阅读订单详情页面中的说明。
在 woocommerce_order_details_after_order_table
操作挂钩中使用自定义挂钩函数,我们在其中添加 woocommerce_thankyou_{$order->get_payment_method()}
挂钩,将完成这项工作:
add_action( 'woocommerce_order_details_after_order_table', 'view_order_custom_payment_instruction', 5, 1); // Email notifications
function view_order_custom_payment_instruction( $order ){
// Only for "on-hold" and "processing" order statuses and on 'view-order' page
if( in_array( $order->get_status(), array( 'on-hold', 'processing' ) ) && is_wc_endpoint_url( 'view-order' ) ){
// The "Payment instructions" will be displayed with that:
do_action( 'woocommerce_thankyou_' . $order->get_payment_method(), $order->get_id() );
}
}
代码进入您的活动子主题(或主题)的 function.php 文件或任何插件文件。
在 WooCommerce 3+ 中测试和工作。
它对我不起作用,我不得不稍微修改一下代码:
add_action( 'woocommerce_order_details_after_order_table', 'view_order_custom_payment_instruction', 5, 1); // Email notifications
function view_order_custom_payment_instruction( $order ){
// Only for "on-hold" order statuses and on 'view-order' page
if( in_array( $order->get_status(), array( 'on-hold' ) ) && is_wc_endpoint_url( 'view-order' ) ){
WC()->payment_gateways();
// The "Payment instructions" will be displayed with that:
do_action( 'woocommerce_thankyou_' . $order->get_payment_method(), $order->get_id() );
}
}
实际上,付款说明显示在“已收到订单”页面上:
我想要的是在我的帐户 > 订单视图页面中也显示此付款说明。
像这样:
我的问题:如何让付款指令出现在我的账户 > 订单查看页面?
我知道它会发送到客户邮箱,但如果他们懒得打开电子邮件,他们可以阅读订单详情页面中的说明。
在 woocommerce_order_details_after_order_table
操作挂钩中使用自定义挂钩函数,我们在其中添加 woocommerce_thankyou_{$order->get_payment_method()}
挂钩,将完成这项工作:
add_action( 'woocommerce_order_details_after_order_table', 'view_order_custom_payment_instruction', 5, 1); // Email notifications
function view_order_custom_payment_instruction( $order ){
// Only for "on-hold" and "processing" order statuses and on 'view-order' page
if( in_array( $order->get_status(), array( 'on-hold', 'processing' ) ) && is_wc_endpoint_url( 'view-order' ) ){
// The "Payment instructions" will be displayed with that:
do_action( 'woocommerce_thankyou_' . $order->get_payment_method(), $order->get_id() );
}
}
代码进入您的活动子主题(或主题)的 function.php 文件或任何插件文件。
在 WooCommerce 3+ 中测试和工作。
它对我不起作用,我不得不稍微修改一下代码:
add_action( 'woocommerce_order_details_after_order_table', 'view_order_custom_payment_instruction', 5, 1); // Email notifications
function view_order_custom_payment_instruction( $order ){
// Only for "on-hold" order statuses and on 'view-order' page
if( in_array( $order->get_status(), array( 'on-hold' ) ) && is_wc_endpoint_url( 'view-order' ) ){
WC()->payment_gateways();
// The "Payment instructions" will be displayed with that:
do_action( 'woocommerce_thankyou_' . $order->get_payment_method(), $order->get_id() );
}
}