0

I'm working with a client to create a WooCommerce shopping site. However, for some reason after people add items do their cart, these items take approximately 30 seconds to actually add to the cart.

I have been able to determine that the WooCommerce session is not being set immediately. Products are being saved in the database, but the session cannot access them until shortly afterwards.

I created a shortcode to print out the sessions so that I can see what's happening. This script is irrelevant, but it is as follows:

function test_func( $atts ){
    $customer = @WC()->session;
    return print_r($customer);
}
add_shortcode( 'test', 'test_func' );

Here is a screenshot of the cart directly after adding the product. Note how it says "Your cart is currently empty" and the _customer_id:protected value:

Sessions print out that doesn't match anything

Here is a screenshot from phpMyAdmin which shows the session being stored:

PHPMyadmin screen shot of sessions

And 32 seconds after the first screen shot, I refreshed the page and this appeared, matching the _customer_id.

Session print out that does match

So my question: why is there a 30-second delay and how can I fix it?

I have already tried changing WooCommerce to go straight to checkout (didn't work) and I have used these tips from BusinessBloomer.com that everybody links to.

I am running WooCommerce v.3.6.5, running WordPress 5.2.2, with PHP version 7.0.33. My host is GoDaddy.

closed as off-topic by Nathan Johnson, fuxia Aug 19 at 16:16

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Hey, try to switch the theme with different theme, then check the process again. if issue not come then the issue is in your theme override woo commerce core files.so then you can check into files. maybe settimeout function used in js. – Techno Deviser Aug 13 at 6:54
  • 1
    You need to first isolate the component that's causing this before going into the details. Switch to another theme as @TechnoDeviser suggested, then if the delay remains, switch off themes one by one until you find the component that's causing this. Once you know, the answer might be apparent already, or you can then look/trace through the code for this component if all else fails. – alexg Aug 15 at 12:26
1
+50

I would try duplicating this site to a staging area.

Then go through and deactivate all of your plugins except for Woo Commerce. With everything disabled except Woo Commerce and your theme, try and add items to your cart. See if there is a delay for things when you add them to the cart.

If there is no delay, slowly activate your plugins one at a time until your find the plugin that is causing the issues. If there is a delay with only your theme and Woo Commerce, then try switching to a different theme.

This way you can slowly narrow things down to determine what is at fault.

  • I checked today and there were a few plugins/database changes that needed updating. Fixing those fixed the issue. I wonder if there was a bug in a previous version... anyway, I appreciate your help. Your answer didn't get me to the solution but it was good advice so you can have the bounty :) – Kenton de Jong Aug 19 at 15:53
  • 1
    No problem! And thank you! :) Sometimes you just need a nudge in the right direction and you can get it solved! – Michael Aug 20 at 16:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.