THE PROBLEM

We discovered the last step of the WooCommerce checkout was very slow, taking about 20 seconds to complete.  The orders eventually went through successfully.  The hangup seemed to be on the ?wc-ajax=checkout stage of the checkout.

In our case the problem was happening with all sites hosted on InMotion VPS servers.  We tested about 6 different sites, and even created a new one.  It was happening on all of them, even a completely different VPS server.  Other sites we tested on other hosts such as Siteground were not experiencing the issue.

It wasn’t the gateway, because it was doing it with just Pay By Check active.

It took almost 2 days to figure this out and we found very little information on the web about it.  There were plenty of olders posts about it, but very few solutions.

 

THE SOLUTION

The email sending was the next area of focus.  It must be hanging up on this process. Turning off the main order notification emails, showed an improvement and brought down to 8-10 seconds. Better than 20, but still unacceptable. Deferring transactional emails entirely is what solved it for us, which processes the emails after the order is submitted.   Adding this filter to the functions.php file resolved the issue.

Add this to your functions.php file.

add_filter('woocommerce_defer_transactional_emails', '__return_true' );

Switching to a new web hosting company and migrating your sites, databases, email and domain settings can be a daunting task for those that haven’t done a large number of them.   This is one of those areas where experience can make a huge difference in the success of the migration and the time it takes.  Many hosts offer free migration, but we always prefer to do it manually so each piece can be verified and tested and so we know everything was covered.  Also most importantly so we can make the DNS changes at the best time to minimize any downtime while it propagates.
Email has always been a piece that can really complicate things.   For those that use their web host as their mail server you need to get all those messages moved over.

The Best Way To Migrate Mail from One Web Server to Another Host.

Use cPanel to Copy over the /etc & /mail directories.

cPanel is key here.  I am a big fan of cPanel, and do not like the current trend of do away with it for proprietary interfaces or command line only.  Especially for WordPress sites, it is an essential tool for managing sites & hosting in my book.  A massive time saver.  Also a reason I do not recommend the Managed WordPress hosting services, such as Kinsta and WP Engine that don’t use a typical cPanel setup.

  1. Use cPanel File Manager.  Compress the /etc and /mail directories.
  2. Download the file
  3. Upload the file to the new host through cPanel file manager and
  4. Extract them in the root and replace the existing etc & mail directories.
  5. Done.  Connect via IMAP and carry on.

Shout out to the awesome support team at InMotion Hosting for this tip.
If you need help with migrating to a new host contact me.