我正在运行WordPress的多站点安装,我已经获得了WooCommerce Points&已安装奖励插件。
查看结帐时,出现此错误。
Notice: Object of class WP_Term could not be converted to int
in /wp-content/plugins/woocommerce-points-and-rewards/includes
/class-wc-points-rewards-product.php on line 547
它所指的代码也是:
$category_ids_string = implode( ',', array_map( 'intval', $category_ids ) );
我试图解决这个问题,但我无法解决这个问题。任何人都可以建议我能解决这个问题吗?
该网站将于下周推出,但地址为:http://bartonsdrinks.com
由于
答案 0 :(得分:0)
$category_ids
可能是一个术语对象数组。它需要是一个单值的数组。
因此循环遍历$category_ids
并将术语id分配给新数组:
// I would rename your: $category_ids to: $categories cause it makes more sense
$categories = $category_ids;
$category_ids = array();
// It would be better if you changed the definition instead of above solution
if( !empty( $categories ) ){
foreach( $categories as $cat ){
$category_ids[] = $cat->term_id;
}
}
$category_ids_string = implode( ',', array_map( 'intval', $category_ids ) );
这应该可以使它发挥作用。