WooCommerce: Product properties should not be accessed directly

I have this error in my staging site:

Notice: sku was called incorrectly. Product properties should not be accessed directly. Backtrace: require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), include(’/themes/x/woocommerce.php’), x_get_view, X_View_Router::render, include(’/themes/x/framework/views/renew/woocommerce.php’), woocommerce_content, wc_get_template_part, load_template, require(’/plugins/woocommerce/templates/content-product.php’), do_action(‘woocommerce_after_shop_loop_item_title’), WP_Hook->do_action, WP_Hook->apply_filters, shop_sku, WC_Abstract_Legacy_Product->__get, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in / [ LOCAL DEV ENVIRONMENT FOLDERS] /wp-includes/functions.php on line 4773

The product images do not show up on the product archive pages. The above notice might not be the culprit, but it’s the only issue I’ve seen.

I tried disabling my x-child theme without any luck. The backtrace points to lots of things, but I can’t make sense of it and can’t find the issue. I did however enable the TwentyNineteen theme and that removed the issue, so I know it’s theme-based.

Using:

  • WordPress 5.2.0 (latest at the time of writing)
  • X Theme 6.5.5 (latest at the time of writing)
  • Cornerstone 3.5.4 (latest at the time of writing)

I found this thread, but it didn’t shed any real light on the issue:

WooCommerce status page also shows this:

x/woocommerce/single-product-reviews.php version 3.5.0 is out of date. The core version is 3.6.0

Another note:

Disabling Cornerstone brought back the product images on the archive page. The sku-notice did not disappear though. Re-enabling Cornerstone made product images invisible again.

Hi @patrikalienus,

May we know which version of WooCommerce plugin you’re using?

Would you mind providing us with login credentials(by clicking on the Secure Note button at the bottom) so we can take a closer look? To do this, you can make a post with the following info:

  • Link login to your site
  • WordPress Admin username / password

Thanks.

I’m using WooCommerce 3.6.2 (latest as of this writing).

I can’t supply you with a login since this is on a local dev environment.

Ok so I finally found the issue to the sku-notice.

There was a line in functions.php that used $product->sku instead of $product->get_sku().

However the product images are still invisible when Cornerstone is activated, so the issue isn’t solved by any means.

I found the reason to why the product image was hidden, but I can’t find where it’s been input’ed.

The pages had some inline CSS that was hiding the product image. I have no idea why this was added, or whom did it, but disabling it brought the product images back.

I have no idea where to edit this CSS however. I searched the DB and it’s within the wp_options table under option name x_custom_styles. Where is this data edited?

Hi @patrikalienus,

The custom CSS codes are put under X > Theme Options > CSS:

Could you please double check?

Thank you.

Ah yes, there it was!

Thanks.

You can mark this thread as solved/closed.

Glad we were able to help :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.