Manually Purging the WooCommerce Shipping Rate Cache

I’ve been working on changing the shipping structure for a client site running WooCommerce. When I started changing the shipping options and refreshing the page, the shipping options weren’t changing. I didn’t know that WooCommerce caches shipping rates for an hour. Once I figured that out, I found the Shipping Debug Mode under WooCommerce -> System Settings -> Tools:

So I checked the box, refreshed the page–and nothing changed. The Debug Mode didn’t seem to be working.

I couldn’t figure out why the debug mode didn’t work. And clearing the transients via the option on that same page wasn’t working either. So I went looking for the value in the database. Once I found and deleted it, refreshing the page finally showed my latest changes to the shipping settings.

Manual Purge

The shipping rates are cached as transients in the ‘wp_options’ table. These transients contain ‘wc_ship_’, so do a LIKE lookup (I’m using phpMyAdmin, but you could do this directly in the console, too):

Screen Shot 2015-01-13 at 8.15.59 PM

Run that query on the ‘wp_options’ table and you should see the transients. Delete them and you should be good to go.

Screen Shot 2015-01-13 at 8.16.07 PM

While it’s not a permanent fix (and a hassle to keep doing while playing with the shipping settings), hopefully this can save someone a few hours of banging their head against a wall. And if you know why the debug mode and clearing transients on the settings page didn’t work, let me know in the comments.

This Post Has 9 Comments

  1. Hi Spencer,
    I faced with the same issue: I cannot Add Cost 1.00 per item into the Costs Added table in woocommerce settings, when I click “save” nothing saved. On my website Flat Rate shipping doesn’t appear at all. I wanted to fix it following your recommendations, but couldn’t understand how to do that (I’m not a professional). I would be very grateful if you please tell me step by step from my WP dashboard how to delete those transients.

    1. Hi Anna–that’s the trick with this solution. There is no way to do it from the WP Dashboard. To manually clear the transients, you need access to the database.

  2. Just a heads up on a few things to anyone that encounters this blog post from google:
    – What Canarius says is not correct. That does not clear out your transients.
    – The method described in this post clears out the transients themselves, but there is also the matter of the transient time that exists in the database. These are harmless, but they do take up space. They get created at the same time as the transient itself. So similarly, you can just search under option_name to find both the transient time, as well as the transient itself, to clear everything out.

    1. Thanks, Adam. Just removed that other comment from Canarius to avoid confusion.

  3. Thank you!!
    This was driving me nuts!

    Do you know if there is a ‘better’ solution to this issue yet?


    1. Not that I know of, but I’ll admit that I haven’t done much with WooCommerce lately. I’ve been mostly working in Shopify these days.

  4. Apparently the shipping debug flag works only if you’re shopping as an admin user – it’s otherwise ignored. Just another way Woo keeps the developers enhancing Woo products on their toes.
    Because Woo caches shipping results based on the $package variable (cart items and addresses etc) it ignores a few other variables I need (receipted delivery, transport assurance etc) which change the price.

    In any case, I was happily deleting the _transient_wc_ship% files, but it wasn’t always working.

    So I checked the relevant Woo methods in class-wc-shipping.php and found in calculate_shipping_for_package($package) { … } this line:

    $stored_rates = WC()->session->get( ‘shipping_for_package’ );

    Whhaaat? You bastards.

    So. My final, scorched earth solution was at the top of my main plugin file, where it as always going to be processed:

    global $wpdb;

    // Delete all the wc_ship transient scum, you aren’t wanted around here, move along.
    // Same as being in shipping debug mode
    $transients = $wpdb->get_col(
    “SELECT option_name FROM $wpdb->options
    option_name LIKE ‘_transient_wc_ship%'”

    if (count($transients))
    foreach ($transients as $tr)
    $hash = substr($tr, 11);

    $transient_value = get_transient(‘shipping-transient-version’);
    WC_Cache_Helper::delete_version_transients( $transient_value );

    WC()->session->set( ‘shipping_for_package’, ” );

    .. and this did the trick.

    And yeah, I’m moving to Shopify too ..

    1. LOL, nice work tracking that down. Woo is crazy. You should definitely come over to the Shopify camp. It’s like a breath of fresh air coming from WordPress and WooCommerce.

Leave a Reply

Close Menu