Methods 向订单收到的电子邮件添加操作时,payment_方法调用错误
我使用此代码显示woocommerce发送的订单接收电子邮件中的其他信息Methods 向订单收到的电子邮件添加操作时,payment_方法调用错误,methods,woocommerce,payment,Methods,Woocommerce,Payment,我使用此代码显示woocommerce发送的订单接收电子邮件中的其他信息 add_action('woocommerce_email_after_order_table', 'add_order_email_instructions', 10, 2); function add_order_email_instructions($order, $sent_to_admin) { if (!$sent_to_admin) { if ( isset( $gateways['cod']
add_action('woocommerce_email_after_order_table', 'add_order_email_instructions', 10, 2);
function add_order_email_instructions($order, $sent_to_admin) {
if (!$sent_to_admin) {
if ( isset( $gateways['cod'] ) == $order->payment_method) {
// cash on delivery method
do_action('woocommerce_thankyou_lieferung', $order->get_id());
} else {
// other methods (ie credit card)
do_action('woocommerce_thankyou_lieferung', $order->get_id());
}
}
}
这给了我错误信息
付款方法调用不正确。不应直接访问订单属性
在debug.log文件中
我找不到上面的代码有什么问题。请尝试下面的代码
add_action('woocommerce_email_after_order_table', 'add_order_email_instructions', 10, 2);
function add_order_email_instructions($order, $sent_to_admin) {
if (!$sent_to_admin) {
if ( isset( $gateways['cod'] ) == $order->get_payment_method()) {
// cash on delivery method
do_action('woocommerce_thankyou_lieferung', $order->get_id());
} else {
// other methods (ie credit card)
do_action('woocommerce_thankyou_lieferung', $order->get_id());
}
}
}