HOMEBlogWooCommerce DevelopmentFree Shipping Progress Bar: Easy WooCommerce Mini-Cart Setup…

Free Shipping Progress Bar: Easy WooCommerce Mini-Cart Setup in 3 Steps

Free Shipping Progress Bar

Shoppers can reach checkout without realizing they are only a few dollars away from free shipping, so they may abandon a useful order incentive. Add a Free Shipping Progress Bar to the classic WooCommerce mini-cart with a small site-specific plugin and a little CSS. The indicator can show how much more the customer needs to spend, then clearly confirm when the configured minimum has been reached.

This guide targets the classic mini-cart widget or a theme that renders the classic mini-cart; the WooCommerce Mini-Cart block needs a different, block-specific integration. Before adding code, identify the free-shipping method and its minimum order amount. The displayed progress must follow the same rules for coupon discounts and tax as the shipping method, or the bar may claim the customer qualifies while checkout still shows a shipping charge. You will then install the plugin, style the status and track, and test cart changes, coupons, and the completed threshold. The result is a server-rendered Free Shipping Progress Bar with accessible status text, not just a visual cue.

  • A WordPress site with WooCommerce installed and active.
  • PHP 8.0 or later and permission to create a small site-specific plugin.
  • A configured shipping zone with a WooCommerce Free shipping method and a known minimum order amount.
  • A staging site or current backup, plus access to the storefront and browser developer tools.
  • A classic WooCommerce mini-cart widget or classic theme mini-cart. If your store uses the Mini-Cart block, review the compatibility notes before implementing this classic-hook approach.

Confirm the Mini-Cart Type and Shipping Rule

First, identify which mini-cart your storefront uses. A classic mini-cart is commonly added as a WooCommerce Mini Cart widget or rendered by a classic theme. The WooCommerce Mini-Cart block is a block-editor component, often placed in a header template in the Site Editor. This guide uses a PHP hook for the classic mini-cart only; it does not add the indicator to the block-based mini-cart.

In WooCommerce, open Settings → Shipping → Shipping zones and find the zone that applies to your test customer address. Record the minimum order amount configured for its Free shipping method. Also check whether the method requires a coupon and whether discounts and tax count toward its minimum. Those settings determine what the progress calculation must measure; the bar should not announce eligibility unless the same cart qualifies for free shipping at checkout.

For Developers
If the storefront uses the WooCommerce Mini-Cart block, do not install the classic-hook implementation unchanged. Use a block-specific extension or integration, and verify its eligibility calculation against the same shipping zone and threshold rules.

Set the Free-Shipping Threshold and Its Calculation Rules

Configure the shipping method before adding a progress calculation so the indicator can use the same qualifying amount as WooCommerce. Go to WooCommerce → Settings → Shipping → Shipping zones, open the zone that applies to your customer’s delivery address, and add or edit its Free shipping method. Set the minimum order amount and choose the method’s requirement, such as a minimum spend, a coupon, or either condition.

Check the method’s Apply minimum order rule before coupon discount setting. When enabled, the minimum is checked before coupon discounts; when disabled, discounts can reduce the qualifying amount. The value shown by the mini-cart must follow that choice. For the example calculation in the next step, use merchandise after discounts, and include tax only when the store’s displayed prices include tax. If your free-shipping rule evaluates the cart before discounts or uses a different tax basis, adapt the calculation to match it rather than relying on this example unchanged.

WooCommerce’s official Free Shipping setup guide describes the method requirements and minimum-spend options. Record the exact threshold and rule for the relevant zone; a different zone may have a different minimum or no free-shipping method at all.

Pro Tip
Before publishing, place a test order using the relevant delivery address and verify that free shipping becomes available at exactly the amount your progress calculation treats as qualifying. Test with a coupon if discounts affect the minimum.

Add the Free Shipping Progress Bar to the Classic Mini-Cart

Create a site-specific plugin so the feature remains active when you change themes and does not modify WooCommerce core. Create wp-content/plugins/pnet-shipping-progress/pnet-shipping-progress.php, paste in the code below, and activate PNet Shipping Progress from the Plugins screen. Change $threshold to the minimum for the shipping zone you are testing.

This example uses the cart contents total after discounts, excluding tax. It adds cart contents tax only when the shop is configured to display prices including tax. The custom pnet_ functions belong to this plugin; they are not WooCommerce core functions. The hook targets the classic mini-cart only.

PHP
<?php
/**
 * Plugin Name: PNet Shipping Progress
 * Description: Shows free-shipping progress in the classic WooCommerce mini-cart.
 * Version: 1.0.0
 * Requires PHP: 8.0
 */

add_action( 'woocommerce_widget_shopping_cart_before_buttons', 'pnet_render_shipping_progress' );

function pnet_render_shipping_progress() {
    if ( ! function_exists( 'WC' ) || ! WC()->cart ) {
        return;
    }

    // Match this amount to the minimum in the applicable shipping zone.
    $threshold = 75.00;
    $cart      = WC()->cart;

    // Cart contents total is after discounts and excludes tax.
    $qualifying_total = (float) $cart->get_cart_contents_total();
    if ( 'incl' === get_option( 'woocommerce_tax_display_shop' ) ) {
        $qualifying_total += (float) $cart->get_cart_contents_tax();
    }
    $qualifying_total = max( 0, $qualifying_total );

    $remaining = max( 0, $threshold - $qualifying_total );
    $percent   = $threshold > 0
        ? min( 100, max( 0, ( $qualifying_total / $threshold ) * 100 ) )
        : 100;
    $aria_now  = min( $threshold, $qualifying_total );

    if ( $remaining > 0 ) {
        $message = sprintf(
            esc_html__( 'Add %s more to unlock free shipping.', 'pnet' ),
            wp_kses_post( wc_price( $remaining ) )
        );
    } else {
        $message = esc_html__( 'Your order qualifies for free shipping.', 'pnet' );
    }

    $state_class = $remaining > 0 ? ' is-incomplete' : ' is-complete';

    echo '<div class="pnet-shipping-progress' . esc_attr( $state_class ) . '">';
    echo '<p class="pnet-shipping-progress__message">' . wp_kses_post( $message ) . '</p>';
    echo '<div class="pnet-shipping-progress__track" role="progressbar" aria-label="' . esc_attr__( 'Free shipping progress', 'pnet' ) . '" aria-valuemin="0" aria-valuemax="' . esc_attr( wc_format_decimal( $threshold, 2 ) ) . '" aria-valuenow="' . esc_attr( wc_format_decimal( $aria_now, 2 ) ) . '">';
    echo '<span class="pnet-shipping-progress__fill" aria-hidden="true" style="width:' . esc_attr( wc_format_decimal( $percent, 2 ) ) . '%"></span>';
    echo '</div>';
    echo '</div>';
}

Once activated, open the classic mini-cart and check that its message and percentage reflect the test cart. The hook runs when WooCommerce renders that mini-cart, so its server-generated markup normally refreshes with classic mini-cart fragments. Confirm that the threshold and discount or tax policy match the shipping method before relying on the completion message.

Free Shipping Progress Bar - Classic Mini-Cart States
Classic Mini-Cart States

You might also like:

WooCommerce Wholesale Pricing: Easily Boost Sales with Flawless Role Prices (2026)

Need WooCommerce wholesale pricing for your clients? Stop relying on heavy plugins and safely code it from scratch. Follow our...

Read more →

Style the Progress Bar and Its Completion State

Add the CSS below in Appearance → Customize → Additional CSS or your child theme stylesheet. The selectors match the classes emitted by the plugin: the outer pnet-shipping-progress element carries either is-incomplete or is-complete, while the message, track, and fill use the corresponding double-underscore classes. No extra JavaScript or PHP changes are needed for these styles.

The compact track is designed to sit neatly above the mini-cart buttons. Its status message remains visible in both states, so shoppers do not have to infer progress from color alone. The completed state changes the message styling and fill color; the reduced-motion rule disables the width animation for visitors who request less motion.

CSS
.pnet-shipping-progress {
    box-sizing: border-box;
    width: 100%;
    margin: 0 0 1rem;
    padding: 0.75rem;
    border: 1px solid #d7dee7;
    border-radius: 0.5rem;
    background: #ffffff;
}

.pnet-shipping-progress__message {
    margin: 0 0 0.5rem;
    color: #1f2937;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.45;
}

.pnet-shipping-progress__track {
    width: 100%;
    height: 0.625rem;
    overflow: hidden;
    border-radius: 999px;
    background: #e5e7eb;
}

.pnet-shipping-progress__fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: #1769aa;
    transition: width 0.25s ease;
}

.pnet-shipping-progress.is-complete {
    border-color: #a7d7b5;
    background: #f2fbf5;
}

.pnet-shipping-progress.is-complete .pnet-shipping-progress__message {
    color: #14532d;
}

.pnet-shipping-progress.is-complete .pnet-shipping-progress__fill {
    background: #18794e;
}

@media (max-width: 480px) {
    .pnet-shipping-progress {
        padding: 0.625rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pnet-shipping-progress__fill {
        transition: none;
    }
}

After saving, check the mini-cart at its narrowest expected width. The track should stay within the dropdown, the text should wrap without clipping, and the completed message should remain legible. If your theme applies stronger mini-cart styles, scope a small override beneath these rules rather than changing the plugin markup.

Free Shipping Progress Bar - Styled Mini-Cart States
Styled Mini-Cart States

Test Thresholds, Cart Changes, and Accessibility

Test the mini-cart against deliberate cart totals before publishing. Start with an empty cart, then add products to create a total below the threshold, one small amount below it, and exactly at or above it. Check that the remaining amount decreases correctly, the visual fill never exceeds 100%, and the completion message appears only when the cart satisfies the configured rule.

Next, add and remove products and apply a coupon that changes the qualifying amount. At each stage, compare the mini-cart message with the shipping options WooCommerce actually offers at checkout using an address in the relevant shipping zone. Repeat with the store’s tax display settings in mind; the amount shown to shoppers and the amount used by the shipping method must agree. Check the dropdown on desktop and at a narrow viewport width for clipped text, overflow, or buttons pushed out of view.

Confirm that the status message is readable without relying on the bar’s color. The progress track includes role="progressbar" and minimum, maximum, and current-value attributes for assistive technology; the adjacent text communicates the remaining amount or successful completion. Verify the message is visible at normal zoom and that keyboard users can continue to the mini-cart controls without getting trapped. The bar itself does not need to be keyboard-focusable because it is a status indicator, not an interactive control.

Classic mini-cart fragments normally refresh server-rendered hook output after cart changes, so first test the theme’s existing update behavior rather than adding JavaScript that could create duplicate or stale markup. If the bar does not update, inspect whether the theme replaces classic mini-cart output or suppresses fragment refreshes, then check caching exclusions, the browser console, and PHP logs.

Free Shipping Progress Bar - Cart State Comparison
Cart State Comparison

Common Errors

If the indicator is missing, shows the wrong amount, or fails to change with the cart, check the integration and the shipping rules separately. The message is only reliable when the classic mini-cart renders the hook and its calculation matches the method used at checkout.

The Hook Does Not Render

This hook targets the classic WooCommerce mini-cart. If your header uses the WooCommerce Mini-Cart block, this implementation will not appear there; use a block-specific integration instead. A theme may also replace or suppress classic mini-cart output, preventing the hook from running. Confirm the mini-cart type and test the classic widget in a staging environment before changing the plugin.

The Bar Is Missing

Check that the plugin is active and that its file has no PHP syntax errors. If a recent edit caused a critical error, review the PHP error log or enable WordPress debug logging on staging to find the reported file and line. The rendering function also returns when WooCommerce or its cart object is unavailable in the current request; test on a normal storefront page with an initialized cart.

The Amount or Completion State Is Wrong

Compare the threshold in the plugin with the minimum configured for the shipping method in the zone that applies to your test address. Then check the method’s minimum-order and coupon settings. The example calculation uses the cart total after discounts and includes tax only when shop prices display tax-inclusive. If the shipping method checks the amount before discounts or uses a different tax basis, the progress calculation must be adapted to match it. Also verify that the customer’s address selects the zone you expect.

The Mini-Cart Does Not Update

If the text stays stale after adding or removing a product, first check whether your theme still refreshes classic mini-cart fragments. A theme that replaces the markup or suppresses fragment updates may need its behavior corrected; adding custom JavaScript immediately can cause duplicate output. Check browser console errors, PHP logs, and cache settings. On staging, temporarily disable page caching and optimization layers, test cart changes and coupons, then re-enable them one at a time and add appropriate exclusions if needed.

You might also like:

WooCommerce Add Custom Field: Easy Guide To “Personalize” The Product

Want to let customers easily add a customized text in product? Learn how to WooCommerce Add Custom Field inputs programmatically...

Read more →

Conclusion

A useful shipping incentive depends on more than a visible meter: the customer-facing message must agree with the shipping method WooCommerce applies at checkout. In this guide, the native Free shipping method supplies the threshold, a small site-specific plugin adds server-rendered progress markup through the classic mini-cart hook, and CSS makes the status compact and clear. The accessible text message and progress attributes ensure shoppers can understand their status without relying on color alone. Keeping the feature in a plugin also avoids editing WooCommerce core or tying the implementation to a parent theme.

Before launch, confirm that the amount calculation matches the applicable shipping zone, including its treatment of coupon discounts and tax. Test an empty cart, totals below and at the threshold, product additions and removals, and any coupons that affect eligibility. Then compare the completion message with the actual shipping options at checkout using an address in that zone. If the storefront uses the WooCommerce Mini-Cart block rather than classic mini-cart output, this hook-based implementation is not the right integration; use a block-specific approach and verify its calculation against the same rules.

Once these checks pass on staging, review the layout on narrow screens and confirm that mini-cart updates keep the status current. A reliable Free Shipping Progress Bar should never promise free delivery prematurely: its completion state and the shipping option available to the customer must agree.

Abhik

🚀 Full Stack WP Dev | ☕ Coffee Enthusiast | 🏍️ Biker | 📈 Trader
Hi, I’m Abhik. I’ve been coding since 2007, a journey that began when I outgrew Blogger and migrated to a robust self-hosted stack. That transition introduced me to WordPress, and I’ve been building professional solutions ever since.

Leave a comment