• Hi there,

    We’re using the WC Save for Later plugin, and recently we started getting a fatal PHP error on our cart page:

    PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given
    in /wp-content/plugins/wc-save-for-later/wpc-save-for-later.php on line 263

    This happens when the cookie used by the plugin is either empty or contains invalid JSON, causing json_decode() to return null.

    Proposed fix:

    In wpc-save-for-later.php, line 263, replace:
    if ( ( $count = count( $products ) ) > 0 ) {

    with:

    if ( is_array( $products ) && ( $count = count( $products ) ) > 0 ) {

    This avoids the fatal error and makes the plugin compatible with PHP 7.2+ and PHP 8+.

    Thanks in advance and hope this can be included in a future release!

    • This topic was modified 11 months, 3 weeks ago by infotbbl.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Support Janilyn T

    (@janilyn409)

    Hi @infotbbl ,

    Thanks for reaching out to us here. I will pass your information to our developers so that they can investigate this further.

    Please check back when you find a new update. This might take pretty much time due to our current heavy workloads.

    Beet regards.

Viewing 1 replies (of 1 total)

The topic ‘Fatal error on line 263 when cookie is empty (count() expects array, null given)’ is closed to new replies.