• We are using a custom function to add a product to cart:
    function add_product_to_cart()
    {
    if (!is_admin())
    {
    global $woocommerce;
    $product_id = $_POST[‘credit_id’];
    $found = false;
    //check if product already in cart
    if ( sizeof( $woocommerce->cart->get_cart() ) > 0 )
    {
    foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values )
    {
    $_product = $values[‘data’];
    if ( $values[“id”] == $product_id )
    $found = true;
    }
    // if product not found, add it
    if ( ! $found )
    $woocommerce->cart->add_to_cart( $product_id );
    } else {
    // if no products in cart, add it
    $woocommerce->cart->add_to_cart( $product_id );
    }
    }
    header(“location:”.$woocommerce->cart->get_cart_url());
    }

    When the cart is empty, we are getting following error from the function in wc-cart “get_cart_from_session”:
    Fatal error: Allowed memory size of 100663296 bytes exhausted (tried to allocate 130968 bytes) in /wp-content/plugins/woocommerce/includes/class-wc-cart.php on line 252

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘WC 2.3.5 add_to_cart allowed memory exhausted’ is closed to new replies.