Skip to main content
Easy Digital Downloads Documentation
Documentation, Reference Materials, and Tutorials for Easy Digital Downloads

Shopping Cart Is Empty at Checkout

Easy Digital Downloads has a native shopping cart system that allows store visitors to add multiple items to their shopping carts before checking out. However, there are a number of host, site, and browser configurations that can break this functionality and cause the cart to appear empty at checkout.

On rare occasions, due to a server configuration, hosting settings, or conflict with other plugins, you may experience your shopping cart being empty after adding an item to your cart. In this article we’ll explain some of the reasons this can happen, and what you can do to resolve the issue.

Caching Plugins

Caching plugins are a very common culprit because they are so widely used. Their purpose is simple – caching plugins speed up load times for your website by storing certain website data for easy access when requested by the browser. While this is a great way to make your site fast and reduce server traffic, some slight changes may be necessary in order to get your shopping cart working correctly.

Disable caching on your Checkout Page

Because the information on your checkout page is specific to a single visitor, it should never be cached as it could produce undesired results for your customers. Adding items to the cart, removing them, calculating cart totals, and all other functions of the checkout page need to reflect the actual state of the page data every time it is loaded. Failing to disable caching on your checkout page can result in a number of issues including customer’s not being able to purchase or having their orders contain incorrect totals, taxes, or products.

If you are using a plugin such as W3 Total Cache, WP Super Cache, or another similar plugin, you must configure it to avoid caching on the checkout page.

If you are using Varnish as a caching layer, you may want to jump to our section about using Varnish with Easy Digital Downloads.

Cloudflare

Cloudflare is a very powerful service for improving your store’s performance and securing your business, and we use on this very site you are on right now. To configure Cloudflare to work with your Easy Digital Downloads powered store, you only need to make a few minimal modifications.

Page Rules

Create the following Page Rules within your Cloudflare settings. Page Rules can be added by clicking Rules → Page Rules → Create Page Rule.

First, from your Cloudflare Site Dashboard find the ‘Rules’ menu on the left, expand it and click on ‘Page Rules’.

This is where you can manage your different page rules and arrange them in order of precedence. It is best to keep your checkout page rule at the top of this list, so that it is the first one to be processed and no other rules will affect your checkout.

To create a Page Rule, click on the ‘Create Page Rule’ button

When creating a Page Rule, you need to define what URLs this rule applies to and what rules you want Cloudflare to apply. For Checkout pages, we want to always bypass Cloudflare’s caching layer so we’ll use the ‘Cache Level’ setting and set it to ‘Bypass’. This means that Cloudflare will send any request for the Checkout page to your server directly.

When adding this Page Rule, ensure that you end the URL with the trailing slash and * character. This will ensure that it matches any query string parameters like discount codes and other features of EDD’s checkout will not be impacted.

Web Host Caching

Though less common, server-side caching can be just as big of a problem for your shopping cart system. Many web hosts offer caching services that you opt into and configure yourself. Others, such as
WP Engine, practice aggressive caching that is pre-configured for you. While these tools can help your store perform better and convert more users, we may need to make some adjustments for a balance of performance and reliability.

WP Engine

If you host your site on  WP Engine, you may encounter some issues with empty carts when visiting the checkout page. This is due to aggressive page caching (which is a good thing!), but it can be easily resolved by requesting that WP Engine setup a special cache exception for your checkout page.

To do this, simply submit a support ticket to WP Engine via their support portal and ask them to exclude your checkout page from cache.

Your checkout page is the one that has the [download_checkout] short code on it, and is saved in Downloads > Settings:

Screenshot from 2013-09-09 12:32:29

To make things really easy for you, feel free to copy and paste this sample ticket:

Hi!

My site runs the Easy Digital Downloads e-commerce plugin and we are having some issues with page caching and the checkout page. The Easy Digital Downloads team has instructed us to ask you to place a cache exception on our checkout page.

Could you please add the following URL to the exception list?

http://YOURSITE.com/{put your checkout page URL here}

Thanks!

Note: While the checkout page may no longer be cached, you may still have a problem with the “Remove” link in your cart not properly removing items from the cart. If this occurs, ask WP Engine to “exclude the ‘edd_saved_cart’ and ‘edd_items_in_cart’ cookies from cache” and that should fix the link.

EasyEngine/Nginx

If you are hosting your site with EasyEngine/Nginx and happen to be using Redis caching, you will have to find and edit your redis.conf (or redis-php7.conf) and add edd_items_in_cart|. So, for example, your exceptions could look something like this:

# Don't use the cache for logged in users or recent commenter
if ($http_cookie ~* "edd_items_in_cart|comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") { set $skip_cache 1; }

Varnish

If you are experiencing empty shopping carts when using a Varnish caching server with your Easy Digital Downloads store, you might try and use the following rules to help prevent this:

In your Varnish Configuration

// Tells Varnish to pass through on the checkout page
if (req.url ~ "checkout") { return (pass); }

// Tells Varnish to pass through on any request with edd_action in the query string
if (req.url ~ "edd_action") { return (pass); }

// Tells Varnish to pass through on any request with add_to_cart in the query string
if (req.url ~ "add_to_cart") { return (pass); }

// Tells Varnish to pass through if any cookies with `edd` are found
if (req.http.cookie ~ "(^|;s*)edd") { return (pass); }

Some Varnish tutorials and configurations suggest re-ordering query string arguments to optimize cache hit rates. This feature of Varnish can result in file download links generated by Easy Digital Downloads to fail, due to the secure link verification it uses. If you want to use this caching technique, we’ve written a helpful guide on how to support query string modification with Easy Digital Downloads, and still give customers access to secure file downloads.

Server does not support PHP Sessions

PHP sessions are designed to give your site visitors a more customized experience. The ability to add items to a shopping cart from page to the next, and then see all of store items in the cart at checkout is about as personal as it gets for a brand new visitor that hasn’t shared any information with your site.

Some servers or hosts do not support using PHP’s native ‘session handler’. Easy Digital Downloads stores your visitor’s cart information in their PHP session, however, when this feature of PHP is not available, it can produce empty carts as the cart data cannot be saved between page views.

Easy Digital Downloads supports storing session data in the database and using cookies help mitigate this issue. Using this version of ‘session’ management is not as fast as using PHP sessions as it relies on the database, however it can resolve the empty cart issue.

To enable Database Sessions, go to Downloads > Settings > Misc > General and set Session Handling to Database Sessions.

To attempt to keep your database performing in an optimal way, Easy Digital Downloads does clean up abandoned sessions twice a day, using WordPress’s WP Cron events.

Blocked admin-ajax.php File

Included in WordPress core is a file called admin-ajax.php which is used heavily throughout WordPress, including Easy Digital Downloads. Blocking access to this file can cause issues with your cart behavior and other aspects of your WordPress site. It is never suggested to block access to this file.

If you are using any security plugins or have aggressive security settings on your server, temporarily disable them and check the cart functionality again. If your security settings block this file, your cart will not work properly.

For more information on blocked admin-ajax.php, see the full documentation.

Blocked /wp-admin/

There are plugins that block access to /wp-admin/ for security purposes, and these sometimes also block access to the previously mentioned admin-ajax.php file, causing the problems listed above.

To test to see if this is the issue, temporarily deactivate admin blocking plugins. If the problem is resolved then you know it was that plugin.

Browser cookies disabled

EDD uses cookies to store information with sessions and keep count of the items in your cart. If your browser cookies are disabled, the shopping cart system may not work as expected.

URL Settings

As mentioned previously, Easy Digital Downloads uses Sessions and Cookies to be able to save a visitors cart data between page visits, so they can have a unique experience on your store. Cookies are pieces of information about the user that are stored in their browser. For security reasons, the cookies that Easy Digital Downloads uses define the store’s URL in their creation. It is important that your WordPress site is configured to maintain the same URL between the page where you add an item to your cart and your checkout page.

This includes the http or https portion of the URL. If you attempt to add a product to the cart on a page that is using http and your checkout page is secured with an SSL, displaying with https, your cart will be empty as the secure checkout page does not have access to the cookie added by the unsecured page you previously used to add the item to the cart.

We suggest that your entire store is loaded in a secure form with https in the URL, including your WordPress URL settings. If your host does not provide you with an SSL certificate for your store, you can obtain one and have your host install it. Ensure your host can configure your site to only load over https, but if they cannot, you can always use Really Simple SSL to force WordPress to load your site with the SSL Secured version every time.

Make sure that whatever you have set under Settings → General is used in all links throughout your site.

In some cases, we have seen where a 3rd party plugin or script installed modifies the Site Address or WordPress address automatically after a certain amount of time. Double check that your Site Address is not being modified in order to keep your store working as expected.

.htaccess rules

The .htaccess file is used by the server to properly route user requests to your pages. WordPress has a set of default rules that we rely on in order for the cart to properly work. If you are having problems with your cart being empty, try and use the default .htaccess configuration set by WordPress.

Known Plugin Conflicts

Although rare, there can be some conflicts between the Easy Digital Downloads shopping cart and other WordPress plugins. While we attempt to work around these with our code, sometimes we cannot and as such we maintain a list of plugins that we cannot guarantee will work well with Easy Digital Downloads. If you run into a known plugin conflict, please reach out to our support team with as much detailed information you can about the conflict and we’ll be happy to look into the issue for you.