WooCommerce checkout slow can cause frustratingly long load times and lead to order errors. In this article, we’ll discuss the causes of slow checkout on WooCommerce (WordPress) and provide effective solutions to fix them. When a user clicks on the order button, the payment page can take up to 4-5 seconds to load before the successful order message appears.
How to fix Woocommerce Checkout Slow, Speed up Checkout Order Page
Checkout in Wordpress (WooCommerce) refers to the process of customers paying for products or services on a website using the WooCommerce plugin. After selecting a product and adding it to their shopping cart, customers are directed to a checkout page where they enter their payment and shipping information before completing the purchase process. A slow website can result in lost customers and decreased conversion rates.
The Need for Speed: Why Your Checkout Page is Slowing Down and How to Fix It
As someone who has experienced slow ordering and payment functions on my own website, I understand the frustration this can cause. In this guide, I will share my insights on the causes of slow checkout and order errors on WooCommerce (WordPress), as well as ways to fix them.
- First, ensure that your website is set up to send emails successfully, and that your server resources (VPS/Hosting) have enough space, including memory, RAM, and CPU, for the function to work properly.
- If there is a plugin or theme on your site that conflicts with WooCommerce, it can significantly slow down email delivery and cause the WooCommerce checkout process to be very slow.
If your website meets the above two conditions, and you are experiencing slow email delivery or slow checkout when using WooCommerce, the cause may be due to the SMTP email sending function of the “Email Cron” system not working properly. WooCommerce uses the Email Cron system to manage and schedule the sending of emails, and if this system is not functioning correctly, it can result in WooCommerce checkout slow. This issue may cause emails to be delayed or not delivered at all.
A simpler way to understand the WooCommerce checkout slow is that when the user clicks the order button, WooCommerce sends an Ajax request to your website and sends an email before displaying the successful order message. This can cause a delay in email delivery, resulting in slow order errors. One solution is to delay sending the email until after the successful payment page is displayed.
Optimizing Your Checkout Process: Solving Slow Order Errors on WooCommerce
There are 2 ways to handle the problem of slow payment WordPress orders. To do this you will need to add a snippet in functions.php or use the Code Snippets plugin:
Method 1: Speed Up WooCommerce Checkout by Delaying Emails (Recommended)
Log in to the admin page, navigate to Plugins->Add New, then find the Code Snippets plugin, install it, and activate it.
Once the Code Snippets plugin is activated, navigate to the “Snippets” menu and select “Add New”. Next, add the code below, save the snippet file, and test. With this modification, your customers can pay quickly.
/**
Fix checkout Email Cron (Slow page checkout after click button)
*/
add_filter( 'woocommerce_defer_transactional_emails','__return_true' );
Method 2: Using Asynchronous Email to Handle Slow Payment Errors in WordPress
With this method, you can use Must-Use Plugins (mu-plugins), which is a feature in WordPress’ plugin management system that allows plugins to be automatically activated on the entire website without any intervention from the user. We will utilize a way to override the “cron_email” function to fix the WooCommerce checkout slow on WordPress.
To use mu-plugins, you need to do the following steps:
- Create a new folder with the name “mu-plugins” in the “wp-content” folder of your WordPress site.
- Create a file in the “mu-plugins” folder with any name you like for example “ EmailSendAsyn.php ”. and add the following content:
<?php
/**
* Plugin Name: Email Send Asynchronously
* Plugin URI: https://arriveddev.com/
* Description: Speed up and optimize WooCommerce checkout page
* Author: arriveddev.com
* Author URI: https://arriveddev.com/
*/
if ( ! defined( 'DOING_CRON' ) || ( defined( 'DOING_CRON' ) && ! DOING_CRON ) ) {
function wp_mail() {
$args = func_get_args();
$args[] = mt_rand();
wp_schedule_single_event( time() + 5, 'cron_send_mail_async', $args );
}
}
function email_send_asynchronously() {
$args = func_get_args();
array_pop( $args );
call_user_func_array( 'wp_mail', $args );
}
add_action( 'cron_send_mail_async', 'email_send_asynchronously', 10, 10 );
- To check if the “EmailSendAsyn.php” class is enabled, you can visit the “Plugins” page in the WordPress admin interface and search for the plugin name “EmailSendAsyn” in the list.
- After completing these steps, you can check the order again. You will notice that your WordPress site no longer experiences slow loading when clicking the checkout button. The success message will now appear immediately, followed by prompt email delivery.
- If there is any problem, just delete the class “EmailSendAsyn.php” and it will be fine.
Those are some of the ways that we shared to fix WooCommerce checkout slow, and to speed up the checkout page on WordPress when using the WooCommerce plugin. If you have any questions, leave a comment below.