woocommerce notice product_type was called incorrectly . Product properties should not be accessed directly

Rameez Iqbal picture Rameez Iqbal · Apr 12, 2017 · Viewed 12k times · Source

I'm having this notice with all products on shop page after updating WooCommerce version to 3.0.

Notice: product_type was called incorrectly . Product properties should not be accessed directly. Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in C:\xampp\htdocs\oye\wp-includes\functions.php on line 4137

any idea how to fix it?

Answer

rafawhs picture rafawhs · Apr 12, 2017

The product_type property is deprecated. Use get_type() to get internal type.

So you need to change this:

$product->product_type;

to this:

$product->get_type();