• Resolved absoluteweb

    (@absoluteweb)


    Hi,

    Sometime $abandoned_cart_arr does not exist on line 1718 of woocommerce-ac.php and I get this Fatal error: Cannot use string offset as an array.
    While waiting for a better solution I added this line above:
    if(!is_array($abandoned_cart_arr)) $abandoned_cart_arr = array();

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor chetnapatel

    (@chetnapatel)

    Hi,

    Thank you for sharing the error message of our plugin.

    When the user comes to the site from abandoned cart reminder email then we are comparing the carts with the last abandoned cart. And “jason_decode” function will return the array.

    We have applied the fix on our staging server. And we will release the same fix in the next plugin update.

    You can fix the issue as below from line number 1711 to 1740 in the same “woocommerce-ac.php” file of our plugin:

    if ( is_array( $current_woo_cart ) && is_array( $abandoned_cart_arr ) ) {
                    foreach ( $current_woo_cart as $key => $value ) {
                        
                       foreach ( $value as $item_key => $item_value ) {
                            $current_cart_product_id   = $item_value['product_id'];
                            $current_cart_variation_id = $item_value['variation_id'];
                            $current_cart_quantity     = $item_value['quantity'];
            
                           if ( isset( $abandoned_cart_arr[$key][$item_key]['product_id'] ) ) {
                                $abandoned_cart_product_id = $abandoned_cart_arr[$key][$item_key]['product_id'];
                            } else {
                                $abandoned_cart_product_id = "";
                            }
                            if ( isset( $abandoned_cart_arr[$key][$item_key]['variation_id'] ) ) {
                                 $abandoned_cart_variation_id = $abandoned_cart_arr[$key][$item_key]['variation_id'];
                            } else {
                                $abandoned_cart_variation_id = "";
                            }
                            if ( isset( $abandoned_cart_arr[$key][$item_key]['quantity'] ) ) {
                                 $abandoned_cart_quantity = $abandoned_cart_arr[$key][$item_key]['quantity'];
                            } else {
                                 $abandoned_cart_quantity = "";
                            }
                            if ( ( $current_cart_product_id != $abandoned_cart_product_id ) ||
                                 ( $current_cart_variation_id != $abandoned_cart_variation_id ) ||
                                 ( $current_cart_quantity != $abandoned_cart_quantity ) )
                            {
                                return false;
                            }
                        }
                    }
                }

    Can you please change the code and let me know if the issue still persists by monitoring the debug log file?

    Please let me know if you have any further queries.

    Regards,
    Chetna Bhutka

    Plugin Contributor chetnapatel

    (@chetnapatel)

    Hi,

    Today, we have released our Abandoned Cart Lite plugin version 4.4 in which I have included the fix of the error message which you had raised.

    Can you please update the plugin to the latest version of our plugin and confirm with us whether everything is working or not?

    Regards,
    Chetna Bhutka

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fatal error: Cannot use string offset as an array’ is closed to new replies.