Home » Php » php – Woocommerce – sizeof(): Parameter must be an array or an object that implements Countable

php – Woocommerce – sizeof(): Parameter must be an array or an object that implements Countable

Posted by: admin February 25, 2020 Leave a comment

Questions:

I need a Solution to fix this Error. CMS WordPress(4.4.21), plugin Woocommerce(2.1.6). PHP(7.3.6)

sizeof(): Parameter must be an array or an object that implements Countable in
/var/www/u0900579/data/www/xxx/wp-content/plugins/woocommerce/includes/wc-conditional-functions.php
on line 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'] ) ) ) );
    }
}
How to&Answers:

What is the content of $_chosen_attributes?
Try to typecast the variable:

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