Order properties should not be accessed directly – 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 incorrectly. Order properties should not be accessed directly. Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in C:xampphtdocsdevwp-includesfunctions.php on line 4137

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

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?

Read more here: Order properties should not be accessed directly – WooCommerce 3.0

Leave a Reply

Your email address will not be published. Required fields are marked *