payment_method 添加操作以订购收到的电子邮件时调用不正确

payment_method called incorrectly while adding an action to order received emails

我正在使用此代码在 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'] ) == $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());
    }
  }
}

这给了我错误信息

payment_method 调用错误。不应直接访问订单属性。

在 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());
    }
  }
}