'"properties should not be accessed directly" issue during WooCommerce 3.0 checkout

My log shows a lot of the following messages:

order_total was called incorrectly. Order properties should not be accessed directly. This message was added in version 3.0.

and it repeats that message for every property on Order.

What is the cause of these messages and what should I do to rectify them?



Solution 1:[1]

WooCommerce 3.0 revamped their code to restrict the direct access of property, you can either change your code like below.

    $OrderID= ( WC()->version < '2.7.0' ) ? $order->id : $order->get_id();
    $shipping_country   = (  WC()->version < '2.7.0' ) ? $order->shipping_country : $order->get_shipping_country();

Or Update your plugins to WC3 compatible.

$order->property : $order->get_property();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mujuonly