如何解决string2“ id”注意:id的调用不正确产品属性不应直接访问回溯:
string(2)“ id” 注意:id被错误地调用。产品属性不应直接访问。回溯: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,woocommerce_related_template '/themes/demo-theme/woocommerce/single-product/related.php'),WC_Abstract_Legacy_Product->__get,wc_doing_it_wrong请参阅WordPress中的调试以获取更多信息。 (此消息是在3.0版中添加的。)在5227行的/wp-includes/functions.php中
解决方法
这很可能是由您模板中的旧文件引起的,而您具有新的Woocommerce版本。修复非常容易,只需按照堆栈跟踪中的描述查找文件“ /themes/demo-theme/woocommerce/single-product/related.php”并替换:
$product->id;
具有:
$product->get_id();
应该对所有出现的“ $ product-> id;”进行此操作。为了摆脱警告
,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() )
) );
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。