skip to Main Content

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

2

Answers


  1. Chosen as BEST ANSWER

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

  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search