Cart doesn’t work with Flatsome, WooCommerce, and Varnish

This is a quick and easy one.

If you’re using the Flatsome3 theme with WordPress and you have Varnish cache running, you’ll find the cart doesn’t work. You add an item, and the sidebar pops up but then it disappears again straight away, and the cart is empty.

Turn off Varnish and problem solved… but that’s not good enough.

Flatsome has a mechanism where the DOM is replaced with AJAX after the initial load. It uses cookies to pass the cart information around, and Varnish caches those by default.

Add these two rules and you’re golden:

URL exclude  ^/(cart|my-account|checkout|addons)

Cookies exclude  .*woocommerce.*

My site is running on Cloudways (which I strongly recommend – my review here), and the config looks like this:

Leave a Reply

Your email address will not be published. Required fields are marked *