订单属性不应直接访问-WooCommerce 3.0 [英] Order properties should not be accessed directly - WooCommerce 3.0

查看:127
本文介绍了订单属性不应直接访问-WooCommerce 3.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将我的本地WooCommerce网站升级到3.0.一切正常运行正常,但是我注意到打开调试后,我收到了数百条以下通知:

I've just upgraded my local WooCommerce website to 3.0. Everything works perfectly as normal, but I've noticed with debugging turned on that I'm getting hundreds of the following notices:

[05-Apr-2017 12:25:00 UTC] PHP Notice: id was called <strong>incorrectly</strong>. Order properties should not be accessed directly. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.0.) in C:\xampp\htdocs\dev\wp-includes\functions.php on line 4137

因此,WooCommerce似乎正在撤消直接调用订单数据的能力.此代码触发的一个示例是我的functions.php文件中的此函数:

So it looks like WooCommerce are pulling back being able to directly call order data. One example this code is being triggered by is this function in my functions.php file:

function eden_woocommerce_order_number($original, $order)
{
    return 'EDN-' . str_pad($order->id, 10, 0, STR_PAD_LEFT);
}

此函数只是在订单ID的开头添加"EDN",并以10个字符填充,但WooCommerce不喜欢我如何调用$order-重写此类函数的最佳方法是什么那个3.0满意吗?

This function simply adds "EDN" to the start of the order ID and pads it by 10 characters, but WooCommerce doesn't like how I'm calling $order - what would be the best way to rewrite such a function that 3.0 is happy with?

推荐答案

它说:"id被错误地称为 .不应直接访问订单属性."

it says "id was called incorrectly. Order properties should not be accessed directly."

尝试$order->get_id()

这篇关于订单属性不应直接访问-WooCommerce 3.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆