【问题标题】:Woocommerce - sizeof(): Parameter must be an array or an object that implements CountableWoocommerce - sizeof():参数必须是数组或实现 Countable 的对象
【发布时间】:2020-05-28 19:16:03
【问题描述】:

我需要解决此错误的解决方案。 CMS Wordpress(4.4.21),插件 Woocommerce(2.1.6)。 PHP(7.3.6)

sizeof():参数必须是数组或者实现了Countable的对象 /var/www/u0900579/data/www/xxx/wp-content/plugins/woocommerce/includes/wc-conditional-functions.php 在第 237 行

function is_filtered() {
        global $_chosen_attributes;

        ERROR! ------>  return apply_filters( 'woocommerce_is_filtered', ( sizeof( $_chosen_attributes ) > 0 || ( isset( $_GET['max_price'] ) && isset( $_GET['min_price'] ) ) ) );
    }
}

【问题讨论】:

  • 错误信息里给你解决方法。传递给count() 的参数,在本例中为变量$_chosen_attributes 必须是实现Countable 的数组或对象。

标签: php wordpress woocommerce


【解决方案1】:

$_chosen_attributes 的内容是什么? 尝试对变量进行类型转换:

return apply_filters( 'woocommerce_is_filtered', ( sizeof( (array) $_chosen_attributes ) > 0 || ( isset( $_GET['max_price'] ) && isset( $_GET['min_price'] ) ) ) );

【讨论】:

    猜你喜欢
    • 2019-01-27
    • 2018-09-05
    • 2019-06-02
    • 2020-12-06
    • 2018-11-18
    • 2019-05-10
    • 2019-10-04
    • 2021-05-30
    相关资源
    最近更新 更多