Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Unlock Free Shipping in WooCommerce Spend $X Amount?

If you’d like to inform users on the cart pages that they need to spend a certain amount to qualify for free shipping, you can display a message. The shipping method called “Free Shipping” will only be enabled once the customer’s cart reaches the specified amount. Once the cart adds up to the required amount, a message will appear saying “You’ve unlocked Free Shipping”.

add_filter('woocommerce_package_rates', 'ts_free_shipping_for_specific_products', 10, 2);

function ts_free_shipping_for_specific_products($rates, $package) {
    $cart_subtotal = WC()->cart->get_subtotal();

    // Adjust the free shipping threshold as needed
    $free_shipping_threshold = 50;
    if ($cart_subtotal >= $free_shipping_threshold) {
        // If cart subtotal is equal to or greater than the threshold, enable free shipping
        unset($rates['free_shipping:1']); // The shipping method radio button value
    }
    return $rates;
}

// Show 'Spend another X amount' on the cart page.
add_filter('woocommerce_cart_totals_before_shipping', 'ts_cart_page_progress_bar', 10);
function ts_cart_page_progress_bar() {
    $cart_subtotal = WC()->cart->get_subtotal();
    $free_shipping_threshold = 50;
    if ($cart_subtotal < $free_shipping_threshold) {
        $cart_remaining = $free_shipping_threshold - $cart_subtotal;
        echo 'You\'re ' . get_woocommerce_currency_symbol() . $cart_remaining . ' away from free shipping!<br><progress id="freeshippingprogress" max="' . $free_shipping_threshold . '" value="' . $cart_subtotal . '"></progress>';
    } else {
        echo 'You\'ve unlocked free shipping!';
    }
}
How to Unlock Free Shipping in WooCommerce Spend $X Amount? - Tyche Softwares

Easily Set Fees & Discounts For Payment Gateways

Finding it difficult to manage all payment gateway fees and adjusting your product pricing accordingly?

The Payment Gateway Based Fees & Discounts Pro plugin is designed to set up fees & discounts for each of your payment modes and simplify your payment process.

Output

This snippet provides free shipping on orders if the cart subtotal equals or exceeds the specified threshold of $50. Additionally, it dynamically displays a progress bar on the cart page.

How to Unlock Free Shipping in WooCommerce Spend $X Amount?

Alternatively, you can also show WooCommerce free shipping before certain time to customers and encourage them to buy the certain item based on the timeframe.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Newest
Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x