• fightingbettas

    (@fightingbettas)


    Hi, love the cart but it keeps throwing this error.. any help?

    Error Details
    =============
    An error of type E_ERROR was caused in line 161 of the file /homepages/37/d844524284/htdocs/clickandbuilds/FightingBettas/wp-content/plugins/cartpops/public/class-cartpops-cart.php. Error message: Uncaught Error: Call to a member function get_cart() on null in /homepages/37/d844524284/htdocs/clickandbuilds/FightingBettas/wp-content/plugins/cartpops/public/class-cartpops-cart.php:161
    Stack trace:
    #0 /homepages/37/d844524284/htdocs/clickandbuilds/FightingBettas/wp-includes/class-wp-hook.php(307): CartPops_Cart->render_cart_contents('')
    #1 /homepages/37/d844524284/htdocs/clickandbuilds/FightingBettas/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
    #2 /homepages/37/d844524284/htdocs/clickandbuilds/FightingBettas/wp-includes/plugin.php(474): WP_Hook->do_action(Array)
    #3 /homepages/37/d844524284/htdocs/clickandbuilds/FightingBettas/wp-content/plugins/cartpops/templates/drawer/drawer.php(24): do_action('cartpops_drawer...')
    #4 /homepages/37/d844524284/htdocs/clickandbuilds/FightingBettas/wp-content/plugins/cartpops/includes/functions/cartpops-template-functions.php(115): require('/homepages/37/d...')
    #5 /homepages/37/d844524284/htdocs/clickandbuilds/FightingBettas/wp-content/plugins/ca
Viewing 1 replies (of 1 total)
  • This may be the same issue we have (but with the paid version). The situation is that if you add up/cross sells to a product, but then later delete one of the products you had included as an up/cross sell, the plugin chokes and causes a fatal error. In this case the error is so bad the user can no longer even load any page on the website till they clear cache.

    We had to add a line of code in file /cartpops-pro/public/class-cartpops-cart.php after line 753:

    Original Code starting at line 750:

    // Gather products and check stock.
    foreach ( $product_ids as $product_id ) {
        $_product           = cartpops_get_product( $product_id );
        $product_cart_ids[] = WC()->cart->generate_cart_id( $product_id );
    
        if ( $_product->is_in_stock() ) {
            $products[] = $_product;
        }
    }

    Updated Code:

    // Gather products and check stock.
    foreach ( $product_ids as $product_id ) {
        $_product           = cartpops_get_product( $product_id );
        $product_cart_ids[] = WC()->cart->generate_cart_id( $product_id );
    
        if ( ! is_object( $_product ) || ! method_exists( $_product, 'is_in_stock' ) ) { continue; }
    
        if ( $_product->is_in_stock() ) {
            $products[] = $_product;
        }
    }

    Where this part has been added after line 753:

    if ( ! is_object( $_product ) || ! method_exists( $_product, 'is_in_stock' ) ) { continue; }

    We’ve been trying to get support for this but no response so far.

Viewing 1 replies (of 1 total)
  • The topic ‘CartPops Throwing error’ is closed to new replies.