methods - 在添加操作以订购收到的电子邮件时,payment_method 调用不正确
问题描述
我正在使用此代码在接收到 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());
}
}
}
推荐阅读
- javascript - 在子项中更改后,动态链接到组件的道具变得未定义
- excel - 连接到受保护的访问 accdb 文件会引发“密码错误”
- sql - 了解 Oracle 函数中的“BULK COLLECT”
- javascript - 将类自动分配给新元素(使用父元素)
- google-cloud-platform - SFTPoperator 获取多个文件
- sql - SQL Server 中的游标性能改进
- selenium - 如何从命令提示符将 json 文件传递给 Nunit3 测试执行
- regex - 通过scala中的正则表达式提取字母数字字符串的特定部分
- pdfbox - 如何使用 pdfbox 使图像充当 pdf 中的超链接
- javascript - js背景视频调整中心