WooCommerce 客户电子邮件中的错误 - payment_method 调用不正确

Error in WooCommerce customer email - payment_method was called incorrectly

我已经为 WooCommerce 设置了自定义支付方式,我在支付过程中没有任何 PHP 错误,但是在客户收到的电子邮件中有这个错误:

Notice: payment_method was called incorrectly. Order properties should not be accessed directly. Backtrace: edit_post, wp_update_post, wp_insert_post, do_action('save_post'), WP_Hook->do_action, WP_Hook->apply_filters, WC_Admin_Meta_Boxes->save_meta_boxes, do_action('woocommerce_process_shop_order_meta'), WP_Hook->do_action, WP_Hook->apply_filters, WC_Meta_Box_Order_Data::save, WC_Order->save, WC_Order->status_transition, do_action('woocommerce_order_status_on-hold_to_processing'), WP_Hook->do_action, WP_Hook->apply_filters, WC_Emails::send_transactional_email, do_action_ref_array('woocommerce_order_status_on-hold_to_processing_notification'), WP_Hook->do_action, WP_Hook->apply_filters, WC_Email_Customer_Processing_Order->trigger, WC_Email->get_content, WC_Email_Customer_Processing_Order->get_content_html, wc_get_template_html, wc_get_template, include('/plugins/woocommerce/templates/emails/customer-processing-order.php'), do_action('woocommerce_email_order_details'), WP_Hook->do_action, WP_Hook->app in /home/username/public_html/site/wp-includes/functions.php on line 5167

这是电子邮件内容的代码,完整代码可用 here:

public function email_instructions( $order, $sent_to_admin, $plain_text = false ) {

    if ( $this->instructions && ! $sent_to_admin && $this->id === $order->get_payment_method && $order->has_status( 'on-hold' ) ) {
        echo wpautop( wptexturize( $this->instructions ) ) . PHP_EOL;
    }
}

我已将 $order->payment_method 更改为 $order->get_payment_method,但仍然收到错误消息。

能指导我调试一下吗?

public function email_instructions( $order, $sent_to_admin, $plain_text = false ) {

    if ( $this->instructions && ! $sent_to_admin && $this->id === $order->get_payment_method() && $order->has_status( 'on-hold' ) ) {
        echo wpautop( wptexturize( $this->instructions ) ) . PHP_EOL;
    }
}

请尝试这样修改。 get_payment_method()