Title: CartPops Throwing error
Last modified: February 21, 2022

---

# CartPops Throwing error

 *  [fightingbettas](https://wordpress.org/support/users/fightingbettas/)
 * (@fightingbettas)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/cartpops-throwing-error/)
 * 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)

 *  [dabeed](https://wordpress.org/support/users/dabeed/)
 * (@dabeed)
 * [4 years ago](https://wordpress.org/support/topic/cartpops-throwing-error/#post-15678844)
 * 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.

 * ![](https://ps.w.org/cartpops/assets/icon-256x256.png?rev=2459769)
 * [CartPops - High Converting Add To Cart Popup For WooCommerce](https://wordpress.org/plugins/cartpops/)
 * [Support Threads](https://wordpress.org/support/plugin/cartpops/)
 * [Active Topics](https://wordpress.org/support/plugin/cartpops/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cartpops/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cartpops/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [dabeed](https://wordpress.org/support/users/dabeed/)
 * Last activity: [4 years ago](https://wordpress.org/support/topic/cartpops-throwing-error/#post-15678844)
 * Status: not resolved