9

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?

3
  • 1
    This surely come from your custom code or from your active theme (also it can be a third party plugin involved in woocommerce). Version 3.0+ is a Mega Major version and a lot of allowed code is now deprecated. So you will have to test everithing. Also that new WooCommerce version have some bugs, just because it's a new release. You will better go backwards and wait some time. The best thing is to have a staging website for testing and debugging... Apr 12, 2017 at 17:03
  • Please try below answer stackoverflow.com/questions/43279193/…
    – mujuonly
    Apr 12, 2017 at 17:06
  • 2
    All Class Objects properties are not accessible anymore directly in WooCommerce 3.0+. you have to use the getter or setter methods instead. In your case you have to use $product with the WC_Product object get_type method this way: $product->get_type();... Apr 12, 2017 at 18:05

2 Answers 2

24

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

2
  • 2
    Thanks.. You saved my lots of time. Apr 21, 2017 at 7:16
  • woocommerce shouldn't get too bloated, but definetly have better outputs about deprecated calls Jun 21, 2018 at 19:30
-2

(in functions.php) tried editing the "Select Options" text in WooCommerce and it gave that error.

Rafawhs answer worked for me too. This: $product->get_type();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.