WooCommerce Shipping Rules: Charge Different Rates by Cart Total

Learn how to set up multiple shipping rates in WooCommerce based on your customers’ cart totals. I’ll show you 3 different free ways to pull this off in WooCommerce.

Flexible Shipping Plugin

Code Snippets Plugin

Timestamps:

  • 0:00 Shipping Zone Demo
  • 0:50 Native Shipping Zones
  • 3:06 How to NOT set up Shipping Zones
  • 6:32 Flexible Shipping Plugin
  • 11:02 Custom Code Snippet

Code Snippet

				
					add_action('woocommerce_cart_calculate_fees', 'custom_dynamic_shipping_rate');
function custom_dynamic_shipping_rate() {
    if (is_admin() && !defined('DOING_AJAX')) return;

    // Remove any existing custom fees
    WC()->cart->fees_api()->remove_all_fees();

    $cart_total = WC()->cart->get_subtotal();
    $shipping_label = '';
    $shipping_cost = 0;

    if ($cart_total <= 50) {
        $shipping_cost = 10;
        $shipping_label = 'Flat rate';
    } elseif ($cart_total <= 100) {
        $shipping_cost = 5;
        $shipping_label = 'Flat rate';
    } else {
        $shipping_cost = 0;
        $shipping_label = 'Free shipping';
    }

    if ($shipping_cost > 0) {
        WC()->cart->add_fee($shipping_label, $shipping_cost, true);
    } else {
        // Add a free shipping "label" with zero cost
        WC()->cart->add_fee($shipping_label, 0, false);
    }
}
				
			

Free Brand Messaging Worksheet

Define Your Voice and Connect with Your Audience

More Free Resources

Let's Work Together

Big ideas start with a quick chat. Let’s talk!