Clear The WooCommerce Shipping Rate Cache

WooCommerce has a performance feature where it caches (saves) shipping rate information for future use in-order speed up system performance and reduce the workload. That's great and all, except that the ‘clear transients' and ‘clear cache' buttons inside of WooCommerce do NOT delete the WooCommerce shipping rate cache; it does clear all other caches and you can even delete active cart sessions, though the shipping rates will never be touched.

When you clear the cache from inside of WooCommerce you can expect it to clear everything right? Especially since it says so! Alas it does not. Even if you enable shipping debugging it will STILL cache shipping rates even though it's specifically not supposed to. It's a horrible bug in WooCommerce but thankfully there is a way around this.

If you've tried the following and your shipping rates still don't update properly check the next sections:

  • Inside of WooCommerce -> System Status -> Tools, you've checked “Shipping Debug Mode”.
  • You've clicked:
    • Clear transients
    • Clear expired transients
    • Clear all sessions
  • Cleared your browser cache and/or used a Private (incognito mode in Chrome, Private Browsing in Firefox) mode in your browser

The Reason:

The reason the WooCommerce shipping rate cache is not cleared is because of a bug in WooCommerce (or maybe even in WordPress) where it does not delete the proper data from the database. I found this out thanks to Spencer Bean where he wrote on his blog about exactly this, so all credit to this solution goes to him. He wrote the blog post Manually Purging WooCommerce Shipping Rate Cache.

Clearing all those caches does not delete the wc_shipping data rows as it should. Don't know why. Thankfully Spencer had the answer.

The (quick) solution:

Fair warning, this is a manual solution. Though here are the quick steps to get rid of the current WooCommerce shipping rate cache:

  1. Log into your websites database (usually done through your webhost using PhpMyAdmin).
  2. Find the “wp_options” table for your site.
  3. Find all rows in the wp_options table using the LIKE operation to find wc_ship. Using PhpMyAdmin this can be done by selecting the wp_options table and then clicking “Search” on the top menu bar, then entering “%wc_ship%” into the “option_name” field.
  4. Select all of the rows, and delete them.

That's it. That'll clear the WooCommerce shipping rate cache and allow you to retrieve all new shipping rates. Once you get some shipping rates, this cache will be filled up again so if you'd like to get fresh rates you'll have to go through the steps above again.

Video tutorial!

If you'd like some visual guidance on how to accomplish this, I made a short 3 minute (and 3 second) video. It'll show you exactly how to get this done.