string(2) "id" Notice: id was called incorrectly. Product properties should not be accessed directly. Backtrace:

string(2) "id" Notice: id was called incorrectly. Product properties should not be accessed directly. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/plugins/woocommerce/templates/single-product.php'), wc_get_template_part, load_template, require('/plugins/woocommerce/templates/content-single-product.php'), do_action('woocommerce_after_single_product_summary'), WP_Hook->do_action, WP_Hook->apply_filters, Avada_Woocommerce->output_related_products, woocommerce_related_products, wc_get_template, include('/themes/demo-theme/woocommerce/single-product/related.php'), 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 /wp-includes/functions.php on line 5227

Solutions

wp-content/themes/Active-Theme/woocommerce/single-product/related.php

/*if ( ! $related = $product->get_related( $posts_per_page ) ) {
    return;
}*/

$related = wc_get_related_products( $product->get_id(), $posts_per_page );

if ( ! $related ) {
  return;
}

$args = apply_filters( 'woocommerce_related_products_args', array(
'post_type'            => 'product',
'ignore_sticky_posts'  => 1,
'no_found_rows'        => 1,
'posts_per_page'       => $posts_per_page,
'orderby'              => $orderby,
'post__in'             => $related,
'post__not_in'         => array( $product->get_id() )
) );

This is probabily caused by an old file in yout template while you have a new Woocommerce version. The fix is quite easy, just look for the file "/themes/demo-theme/woocommerce/single-product/related.php" as described in the stack trace and replace:

$product->id;

with:

$product->get_id();

That should be done for all the occurrences of "$product->id;" in order to get rid of the warning

Similar questions

Notice: register_uninstall_hook was called incorrectly
I automatically updated my wordpress installation to the latest version. Everything looked normal unit "updating database..." where it got stuck. I waited for a long while and then closed the page, since nothing was happening. Then I got a error message saying something about maintenance, which I got rid of after deleting the maintenance file. Word...
Notice: wp_enqueue_script was called incorrectly
So I'm busy in Wordpress. I have a theme for the site and all. It's all working fine. Then I want to activate the new theme. BENG BENG, white screen of death. I debugged and this is the error: Line 2944 is just the line that throws an error. I already checked that. Anyone ever experienced and solved this? EDIT: Referencing lines:
Notice: wp_enqueue_script was called incorrectly. in Wordpress debug mode
The Code above is working and my postlike system is working fine like that, however Im getting Notice: wp_enqueue_script was called incorrectly. in wordpress debug mode but its working. When I try to do it as a function in the right way the like buttons not working the javascript is broken and also when I try to add this only for single pages using...
Woocommerce - internal server error: Notice: id was called incorrectly
My site has a problem. On checkout I get the Internal server error. I have read almost all the solutions provided on forums and even on this forum but none proved to solve this problem. Here is the error log below. Notice: id was called incorrectly. Order properties should not be accessed directly. Backtrace: require(‘wp-blog-header.php’), require_...
Notice: register_rest_route was called incorrectly
In my Wordpress site, this issue appears when adding or editing posts. Note: I didn't make any WP update or any plugin update on the site. Any idea to fix this issue? Thank you.
Getting notice is wordpress "WP_Scripts::localize was called incorrectly"
Complete message: Notice: WP_Scripts::localize was called incorrectly. The $l10n parameter must be an array. To pass arbitrary data to scripts, use the wp_add_inline_script() function instead. Please see Debugging in WordPress for more information. (This message was added in version 5.7.0.) in /home3/dduconne/public_html/wp-includes/functions.php o...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy .