1

I keep getting the error below when adding an item to my cart. It just started showing up and I have more than enough memory left in the database. I have searched online to find a solution and I have tried all of them: editing the php.ini, editing .htaccess and putting a php.ini in wp-admin. Any help will be greatly appreciated.

Fatal error: Allowed memory size of 125829120 bytes exhausted (tried to allocate 65484 bytes) in /homepages/22/d515555101/htdocs/wp-content/plugins/woocommerce/includes/class-wc-cart.php on line 259

4
  • 1
    Perhaps some part of the script is consuming more memory than its specified by default. You can increase it using ini_set('memory_limit', '2048M'); Or better to find out the reason why its taking so much memory. Commented Mar 26, 2015 at 19:15
  • 1
    increase the memory for PHP wordpress.org Commented Mar 26, 2015 at 19:19
  • Thanks for the comments back. This has been helpful in finding a solution. Looking in to why it is taking up so much memory. Commented Mar 26, 2015 at 19:48
  • 1
    try looking at /var/log/httpd/access_log or error_log. also enable mysql slow query log and tailf /var/log/mysql/slow-log; it'll help you figure out what's taking up so much memory when adding item to cart. Commented Mar 26, 2015 at 19:52

3 Answers 3

4

Find the default-constants.php file on wordpress\wp-includes folder.
Try changing line 23 :

define('WP_MEMORY_LIMIT', '40M');  

to :

define('WP_MEMORY_LIMIT', '128M');
Sign up to request clarification or add additional context in comments.

Comments

0

Are you using WooCommerce Tickets plugin by Modern Tribe? If so, then you need to download the latest version (3.9.2) and install that. (You'll likely need to deactivate and delete the old version). For some reason it's not giving alert that an upgrade is available.

I had tried everything suggested on other forums and finally found this solution and it was the only thing to solve my problem. Hope it helps you!

Comments

0

Maybe you have the bad hook. look at this exemple : i had the same error before

Allowed memory size of 1317011456 bytes exhausted (tried to allocate 262144 bytes) in /home/mala4322/antivirusedition.nash-project.name/wp-content/plugins/woocommerce/includes/class-wc-cart.php on line 623

I changet add_action( 'woocommerce_cart_updated', [$this, 'sauver_champs_perso_panier'] ); for        add_action( 'woocommerce_update_cart_action_cart_updated', [$this, 'sauver_champs_perso_panier'] );
and it was solved
 public function __construct() {

         // Lors du UPDATE CART → on ajoute les données
       add_action( 'woocommerce_update_cart_action_cart_updated', [$this, 'sauver_champs_perso_panier'] );

        // Réafficher dans le panier
        add_filter( 'woocommerce_get_item_data', [$this, 'afficher_donnees_panier'], 10, 2 );

        // Sauvegarde dans la commande lors du checkout
       // add_action( 'woocommerce_checkout_create_order_line_item', [$this, 'sauver_donnees_dans_commande'], 10, 4 );

       
       // add_action( 'woocommerce_update_cart_action_cart_updated', [$this, 'save_custom_cart_item_data']);


    }


    /**
     * Sauvegarde des champs quand l'utilisateur clique "Update Cart"
     */
    function sauver_champs_perso_panier() {
        
        foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {

            // Durée perso
            if ( isset($_POST['alm_duree'][$cart_item_key]) ) {
                $duree = sanitize_text_field( $_POST['alm_duree'][$cart_item_key] );
                WC()->cart->cart_contents[$cart_item_key]['alm_duree'] = $duree;
            }

            // Client perso
            if ( isset($_POST['alm_client'][$cart_item_key]) ) {
                $client_id = intval($_POST['alm_client'][$cart_item_key]);
                WC()->cart->cart_contents[$cart_item_key]['alm_client'] = $client_id;
            }
        }

        WC()->cart->set_session();
    }
New contributor
User User is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.