• Resolved Olivier

    (@pumpk1in)


    Hi !

    I updated a website with woocommerce 2.1.12 (old one, yep)
    I now have the latest Woocommerce and WordPress.

    To be sure, as we have a lot of custom edits in our theme, I used the twenty nineteen theme for the tests. I also disabled WPML as we use it.

    The problem is that this simple function is slow as hell :

    $product_id = 273;
    $quantity = 1;
    $variation_id = 4227;
    WC()->cart->add_to_cart( $product_id, $quantity, $variation_id);

    This product have 11 variations.

    I’m using microtime to measure the time it takes to add product on cart.

    It can take 500ms when it’s fast (nice timing) but 9 times out of 10 it takes +/- 2seconds.
    So, when we use that function with an ajax call, to add products on cart, it can take up to 5-6 seconds (!!) to see the cart updating value…

    In the js file I measured the 5-6 seconds delay right after this line : $.post( wc_add_to_cart_params.ajax_url, parameters, function( response ) {

    This is not a mysql problem, the query time is +/- 0.03seconds.

    Any help ?

    Thanks

    • This topic was modified 5 years, 5 months ago by Olivier.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Can you demonstrate the problem on your site? Please only post what you’re comfortable with being public as we won’t redact the URL.

    Thread Starter Olivier

    (@pumpk1in)

    Hi, well I just found that it only occurs when I am logged in AS ADMIN.
    As a guest, or with a customer account, everything is butter smooth.

    There is something wrong here.

    (So I can give admin access if needed…)

    • This reply was modified 5 years, 5 months ago by Olivier.
    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Please don’t give away your admin details, nobody here is in a position to log into your site. Which plugins do you have active on your site?

    Thread Starter Olivier

    (@pumpk1in)

    It’s a development copy, not the live site but I found the problem.

    I don’t know why, but one plugin is the bad guy : Chronopost (https://www.chronopost.fr/fr/plateformes-e-commerce)

    I’ll see with them.

    Thanks !

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Very slow add_to_cart function’ is closed to new replies.