Shipping is an important factor for the customers while shopping online. Usually store owners give a variety of shipping options to customers so they are more inclined to finish their purchase.
For example, some store owners give discount on the shipping costs if customers purchase a certain number of products, or allow free shipping for certain zones near the store.
The one thing e-commerce store owners know is that customers love free shipping when buying products. This is often tied to a minimum order total for free shipping. You can let the customers know how much more they need to shop so as to avail the free shipping.
By default, WooCommerce provides three shipping methods which can be added for shipping zones based on different regions. In a way, these are very limited. These limitations can be overcome by using some advanced shipping plugins.
WooCommerce has a setting where we can set the minimum amount required for free shipping. It displays an option for free shipping if that much amount of products have been purchased. However, WooCommerce doesn’t provide a way to show a message to the user as to what is the minimum amount required to get free shipping. That’s a big drawback. We will see how to overcome that.
Set Minimum Order Amount for Free Shipping
To set the free shipping minimum amount, go to Dashboard > WooCommerce > Settings > Shipping > Shipping Zones.

If you hover over ‘Free Shipping’, you will see the edit option. On the edit screen, you can choose whether you want to set the minimum amount, a minimum amount for free shipping with a coupon, etc.

So now we have set $500 as the minimum order amount that is required to get free shipping on any WooCommerce order. We will now see how to show the remaining amount to get free shipping on the cart & checkout page.
Where to Add Custom Code in WooCommerce?
It is advisable to add the code snippets to the functions.php file of your child theme. Access the file directly from Appearance->Theme File Editor->Locating the child theme’s functions.php from the right sidebar. You can also access it from your theme’s directory file. Insert the following code snippet in functions.php. The alternative & easy option is to install & activate the Code Snippets plugin. You can then add the code as a new snippet via the plugin.
Show Amount Left for Free Shipping on Cart Page
We will display the notice above the cart with the WooCommerce hook woocommerce_before_cart. This notice will be displayed only when the cart total is less than the minimum amount required for free shipping. We need the total amount from the cart and we already have the minimum amount required for free shipping. We need to display the difference between these two in the notice.
add_action( 'woocommerce_before_cart', 'ts_add_notice_free_shipping' );
function ts_add_notice_free_shipping() {
$free_shipping_settings = get_option('woocommerce_free_shipping_1_settings');
$amount_for_free_shipping = $free_shipping_settings['min_amount'];
$cart = WC()->cart->subtotal;
$remaining = $amount_for_free_shipping - $cart;
if( $amount_for_free_shipping > $cart ){
$notice = sprintf( "Add %s worth more products to get free shipping", wc_price($remaining));
wc_print_notice( $notice , 'notice' );
}
}
In the above example, we get the free shipping settings from our wp_options table. Then we get the cart subtotal and calculate the remaining amount. We display the notice using wc_print_notice() if the amount left for free shipping is greater than the cart total.

The option for “Free shipping” won’t appear on cart page as far as the order total is below the minimum required order amount. But once the cart total reaches your minimum amount ( which in this example is $500 ), it will give an option for free shipping as well.

As you can see, the cart page gives an option to select a shipping method. But you may want to display only the “Free shipping” method & hide the other shipping methods (like “Flat rate”), as the order total has already reached the minimum amount for the free shipping option. Let’s see how we can do that.

Wondering how to bring back your Abandoned cart users?
Abandoned Cart Pro for WooCommerce is loaded with useful features that help you send an effective volume of reminders via text, email, and messenger. You can also share and manage discount codes that will encourage your customers to complete their orders.
Even better, you can stop the cart abandonment with the exit intent popup!
Show Amount Left for Free Shipping on Checkout Page
We can display the notice on the checkout page in the same way as the cart page. Our function will be same but we will use a different filter for the checkout page. Of course, the filter/hook depends on the position you want to display the notice. We will display it above the checkout form using the woocommerce_before_checkout_form hook.
add_action( 'woocommerce_before_checkout_form', 'ts_add_notice_free_shipping' );
function ts_add_notice_free_shipping() {
$free_shipping_settings = get_option('woocommerce_free_shipping_1_settings');
$amount_for_free_shipping = $free_shipping_settings['min_amount'];
$cart = WC()->cart->get_subtotal();
$remaining = $amount_for_free_shipping - $cart;
if ( $amount_for_free_shipping > $cart ) {
$notice = sprintf( "Add %s worth more products to get free shipping", wc_price( $remaining ) );
wc_print_notice( $notice , 'notice' );
}
}
The notice will now show up above the checkout form.

Display Different Remaining Amount for Free Shipping Based on Different Shipping Zones
Encouraging customers to add more products to their cart by displaying the amount left for free shipping is a powerful strategy to boost sales. While a single free shipping threshold works for many stores, some businesses require varying thresholds based on customer location or shipping zones.
This functionality is especially useful for stores catering to customers in multiple regions with different free shipping minimums. For example:
- A customer from the Netherlands should see “Add $40.00 worth more products to get free shipping”, where the free shipping threshold is $40.
- Meanwhile, a customer from Belgium should see “Add $50.00 worth more products to get free shipping”, as their threshold is set to $50.
add_action( 'woocommerce_before_cart', 'ts_add_notice_free_shipping_zone_based' );
function ts_add_notice_free_shipping_zone_based() {
// Get customer shipping country
$customer_shipping_country = WC()->customer->get_shipping_country();
// Define minimum order amounts for free shipping per zone
$minimum_order_amounts = array(
'NL' => 40, // Netherlands
'BE' => 50 // Belgium
);
// Check if the customer's country is in our defined zones
if ( isset( $minimum_order_amounts[ $customer_shipping_country ] ) ) {
$amount_for_free_shipping = $minimum_order_amounts[ $customer_shipping_country ];
$cart = WC()->cart->subtotal;
// Calculate the remaining amount needed for free shipping
$remaining = $amount_for_free_shipping - $cart;
if ( $remaining > 0 ) {
$notice = sprintf(
"Add %s worth more products to get free shipping",
wc_price( $remaining )
);
wc_print_notice( $notice, 'notice' );
}
}
}
function ts_add_notice_free_shipping_zone_based() {
// Get customer shipping country
$shipping_country = WC()->customer->get_shipping_country();
// Fetch free shipping settings dynamically using instance IDs
$free_shipping_settings = array(
'NL' => get_option( 'woocommerce_free_shipping_56_settings' ), // Netherlands
'BE' => get_option( 'woocommerce_free_shipping_57_settings' ), // Belgium
);
// Initialize the minimum order amount
$threshold = 0;
// Check if the customer's shipping country has free shipping settings
if ( isset( $free_shipping_settings[ $shipping_country ] ) ) {
$settings = $free_shipping_settings[ $shipping_country ];
$threshold = isset( $settings['min_amount'] ) ? (float) $settings['min_amount'] : 0;
}
// Only proceed if a threshold is set
if ( $threshold > 0 ) {
// Get the current cart subtotal
$cart_total = WC()->cart->subtotal;
// Check if the cart total is below the threshold
if ( $cart_total < $threshold ) {
$remaining = $threshold - $cart_total;
// Create a notice message
$message = sprintf(
__( 'Add %s more to your cart to qualify for free shipping!', 'woocommerce' ),
wc_price( $remaining )
);
// Display the notice
wc_print_notice( $message, 'notice' );
}
}
}
// Hook into cart and checkout pages
add_action( 'woocommerce_before_cart', 'ts_add_notice_free_shipping_zone_based' );
add_action( 'woocommerce_before_checkout_form', 'ts_add_notice_free_shipping_zone_based' );
When a product costing $10 is added to the cart, we will see the output notice messages based on the following scenarios.
Belgium Scenario:
If the customer selects Belgium as the shipping country, the code will compare the cart subtotal ($10) against the threshold ($50).The difference ($50 – $10 = $40) is calculated and the
notice is displayed as: “Add $40.00 worth more products to get free shipping.”
Netherlands Scenario:
- If the customer selects the Netherlands, the code adjusts to the country’s threshold ($40). The difference ($40 – $10 = $30) is calculated and the notice is displayed as: “Add $30.00 worth more products to get free shipping.”
Show the Amount left while 2 Free Shipping Methods are available
Let’s consider that you have 2 Free shipping methods as Free shipping via Post & Free shipping via courier. The foremost step is to create these methods in WooCommerce settings. Go to Dashboard > WooCommerce > Settings > Shipping > Shipping Zones.
And then, set the free shipping minimum amount for these two methods.

You can define the minimum order amount required for availing of free shipping using these methods, as illustrated in the provided image below. As per the code, the minimum order amount to avail of Free shipping via post is set to $50. And the minimum order amount to avail of Free shipping via courier is set to $100.


The code is intended to showcase a message when the cart with a subtotal that falls below the minimum requirement for availing of free shipping via the courier method.
add_action( 'woocommerce_before_cart', 'ts_free_shipping_cart_notice' );
function ts_free_shipping_cart_notice() {
$min_post_amount = 50; // Minimum amount for free shipping via post
$min_courier_amount = 100; // Minimum amount for free shipping via courier
$subtotal = WC()->cart->subtotal;
$courier_notice = '';
if ( $subtotal < $min_courier_amount ) {
$courier_remaining = wc_price( $min_courier_amount - $subtotal );
$courier_notice = sprintf( 'Add %s worth more products to get free shipping via courier', $courier_remaining );
} else {
$courier_notice = 'You qualify for free shipping via courier!';
}
$return_to = wc_get_page_permalink( 'shop' );
$notice = sprintf(
'<a href="%s" class="button wc-forward">%s</a><br>%s',
esc_url( $return_to ),
'Continue Shopping',
$courier_notice
);
wc_print_notice( $notice, 'notice' );
}
Output 1
The presented image illustrates a cart subtotal of $80, which is below the minimum requirement of $100 for qualifying for free shipping via the courier method. So, the notice message such as “Add $20.00 worth more products to get free shipping via courier!” is displayed.
Cart Subtotal is Below the Minimum for Courier Shipping

Output 2
The image illustrates a cart subtotal of $120 that exceeds the minimum requirement for free shipping via the courier method. The cart contains products with a combined value that fulfills the specified threshold for free shipping via post & via courier.
Cart Subtotal Qualifies for Free Shipping via Courier

The provided output images also demonstrate how the shipping methods adjust dynamically according to the specified threshold values for each of the Free shipping methods.
If you have any questions or feedback, or if you’d like to share your own experiences with these methods, feel free to leave a comment below.

56 thoughts on “Display the remaining cost for customer to avail free shipping on your WooCommerce store”
Hi, thank you for the guide and code. I am using this for while now/ Works like a charm.
Question
I have 2 zones. For zone 1 (Netherlands) the minimum order amount for free shipping is €40 and for zone 2 (Belgium) it is €50 .
How would I make that the correct minimum is used when displaying the message. So if a customer from the Netherlands orders for say € 35 the message says “Add €5 worth more products to get free shipping” and when a customer from Belgium oder € 35 it displays “Add €15 worth more products to get free shipping”.
Love to hear from you.
To be precise. I am using the code for “Show Amount Left for Free Shipping on Cart Page”
Got it working, Used diffrent code. For anyone lookimng for the same solution.
Replace free_shipping_1 and free_shipping_4 with the ID’s of the freeshipping of the correct zone
function gratis_verzending_melding() { // Verkrijg het verzendadres van de klant $shipping_country = WC()->customer->get_shipping_country(); // Verkrijg de drempelbedragen per zone $free_shipping_settings = get_option('woocommerce_free_shipping_1_settings'); $amount_for_free_shipping_nl = $free_shipping_settings['min_amount']; $free_shipping_settings_be = get_option('woocommerce_free_shipping_4_settings'); $amount_for_free_shipping_be = $free_shipping_settings_be['min_amount']; // Verkrijg het huidige winkelmandbedrag $winkelmand_bedrag = WC()->cart->subtotal; // Stel drempelbedrag in op basis van de verzendzone if ($shipping_country == 'NL') { // Zone 1 (bijvoorbeeld Nederland) $drempel_bedrag = $amount_for_free_shipping_nl; } elseif ($shipping_country == 'BE') { // Zone 2 (bijvoorbeeld België) $drempel_bedrag = $amount_for_free_shipping_be; } else { // Standaard drempelbedrag als geen specifieke zone wordt gedetecteerd $drempel_bedrag = $drempel_bedrag_zone_1; } // Controleer of het winkelmandbedrag lager is dan het drempelbedrag if ( $winkelmand_bedrag < $drempel_bedrag ) { $verschil = $drempel_bedrag - $winkelmand_bedrag; echo '<div class="gratis-verzending-melding" style="padding: 10px; background-color: #f8f8f8; border: 1px solid #ddd; text-align: center; font-size: 16px;">'; echo 'Voeg nog <strong>' . wc_price($verschil) . '</strong> toe om gratis verzending te krijgen!'; echo '</div>'; } } add_action( 'woocommerce_before_cart', 'gratis_verzending_melding' ); add_action( 'woocommerce_before_checkout_form', 'gratis_verzending_melding' );Hi Edwin,
Thank you for sharing your solution ! We’ve updated the post to include the requirement of showing the remaining amount for different free shipping thresholds based on different shipping zones.
Hello, Thank you for your informative guide.
I would like to implement something like this to our website. Instead of free shipping we would like it to advertise a free product ” Spend X worth more and get Free Y”
With some minor adjustments to the code this seems possible.
However we would like to got a step further.
We would like a ” Spend X worth more and get Free Y” notification to appear, as a pop up when a customer is close to the X amount.
For example Spend £50 and get a free T shirt, if a customer has £45 of products in the basket a notification could appear saying spend £5 more and you can get a free T shirt.
Is this possible?
Is this something any of your plugins can do?
Thank you
Hi Nicholas,
For your specific requirement, please refer to our post “How to Set Up a BOGO Deal: Spend X More and Get a Free Product Based on Cart Amount in WooCommerce?“
Hello all
if i need to display the notice on the checkout page and cart page to be (Add (20.00 our currency is ILS ) worth more products to get 10% discount) , is it possible , ?? what the codes will be ??? , please help
Hi Abed,
Below is the code for your specific requirement and also refer to the output here:
https://prnt.sc/KEShMvFGXj1C
https://prnt.sc/kStoTC8QC6cV
// Hook to display notice on cart page add_action('woocommerce_before_cart', 'ts_add_discount_notice'); // Hook to display notice on checkout page add_action('woocommerce_before_checkout_form', 'ts_add_discount_notice'); function ts_add_discount_notice() { $discount_percentage = 10; // Change this to the desired discount percentage $currency_symbol = '₪'; // ILS currency symbol $discount_amount = 20; $notice = sprintf("Add %s worth more products to get %d%% discount", $currency_symbol . number_format($discount_amount, 2), $discount_percentage); wc_print_notice($notice, 'notice'); }Hello,
with the code for checkout page message “reads” only nett prices of the products. How should I change the parameter $cart = WC()–>cart->get_subtotal();
to obtain gross prices of the product (price including tax) without shipping costs?
Because I have prices including tax on products and if you buy over 150 EUR worth of products (including taxes), you get free shipping.
Hi,
To display gross prices (including tax) without shipping costs in the checkout page message, you can include these lines of code that follows:
// Use get_cart_contents_total to get the subtotal
$subtotal = WC()->cart->get_cart_contents_total();
// Use get_cart_contents_tax to get the total tax amount
$tax = WC()->cart->get_cart_contents_tax();
$cart = $subtotal + $tax;
$remaining = $amount_for_free_shipping – $cart;
Please refer to the output screenshot: https://prnt.sc/8-Zm_TIkNqpa
Hello, I have tried to add this snippet but I got critical error on the page.
Kind regards,
Peter
Hello,
I followed the procedure for checkout page notification and it works perfectly. I even managed to modify code so I could translate it using wpml string translation and gave it an id so I could customize it’s color via css.
But I still have one issue. The amount for free shipping is’t shown correctly. I have set free shipping above 150 EUR but with this code the amount is about 20 EUR higher.
For example. 150 EUR is minimum amount for free shipping. I’ve put the coat that has price of 107 EUR in the basket and went to checkout and I got notification that I still need 63 EUR instead 43 EUR to get free shipping.
Than I aded sweater of approx 50 EUR and notice was showing I still need 13 EUR but at the bottom free shipping was allready enabled.
Does this has something to do with currency? Should I use € instead of $ in some parts of the code?
Thank you for your answer.
Kind regards,
Peter
Hi Peter,
You’re welcome and glad to know that the code is working well for you. Since you have modified the code, the problem might be due to how the currency is formatted. Also, just to clarify, the $ symbol in the code refers to a variable that starts with the $ sign in PHP, and it doesn’t represent any currency. Could you please share the exact modified code? That way, we can help you figure out the issues.
Hello, thank you for your feedback. Sure thing, here is my code:
add_action( ‘woocommerce_before_checkout_form’, ‘ts_add_notice_free_shipping’ );
function ts_add_notice_free_shipping() {
$free_shipping_settings = get_option(‘woocommerce_free_shipping_3_settings’);
$amount_for_free_shipping = $free_shipping_settings[‘min_amount’];
$cart = WC()->cart->get_subtotal();
$remaining = $amount_for_free_shipping – $cart;
if ( $amount_for_free_shipping > $cart ) {
$notice = sprintf( __(“Add %s worth more products to get free shipping”,”woocommerce”), wc_price( $remaining ) );
wc_print_notice( $notice , ‘notice’, array(‘id’ => ‘do-brezplacne-postnine’) );
}
}
kind regards,
Peter
Hello, I just received this message from your developers:
To display gross prices (including tax) without shipping costs in the checkout page message, you can include these lines of code that follows:
// Use get_cart_contents_total to get the subtotal
$subtotal = WC()->cart->get_cart_contents_total();
// Use get_cart_contents_tax to get the total tax amount
$tax = WC()->cart->get_cart_contents_tax();
$cart = $subtotal + $tax;
$remaining = $amount_for_free_shipping – $cart;
Where exactly should I add/include this code in the upper one so there would be no erros? Or in other words, how would the whole code look like from top to bottom.
Very nice thank you for your time and willingness to help! 🙂
Hi Peter,
Please make sure you have replaced the code correctly. Here is the full script given below.
add_action( ‘woocommerce_before_checkout_form’, ‘ts_add_notice_free_shipping’ );
function ts_add_notice_free_shipping() {
$free_shipping_settings = get_option(‘woocommerce_free_shipping_5_settings’);
$amount_for_free_shipping = $free_shipping_settings[‘min_amount’];
// Use get_cart_contents_total to get the subtotal
$subtotal = WC()->cart->get_cart_contents_total();
// Use get_cart_contents_tax to get the total tax amount
$tax = WC()->cart->get_cart_contents_tax();
$cart = $subtotal + $tax;
$remaining = $amount_for_free_shipping – $cart;
if( $amount_for_free_shipping > $cart ){
$notice = sprintf( “Add %s worth more products to get free shipping”, wc_price($remaining));
wc_print_notice( $notice , ‘notice’ );
}
}
Great! Thank you!!! It works now as it should.
Big respect.
Kind regards,
Peter
Hi,
I have checked the code and, I didn’t find any issues in showing the amount for free shipping. Kindly recheck whether you have used the correct Free shipping ID from the respective shipping zone. Also, make sure that the ID of that specific free shipping minimum value is set to 150.
Hi, I am trying to show Chinese notice in the cart, but seems sprintf() does not work with Chinese characters. someone please help me, Thanks!!
Hi Jan, The sprintf() function should work fine with Chinese characters too, just like any other characters work. Please provide me with the exact error that you encounter so that I can help you better.
Please refer to the link I’ve provided, which has been tested with Chinese characters.
https://prnt.sc/s7tzQrwDuWz8
This problem has troubled me for a long time, and I finally solved it after seeing your article, thank you
Hi elon,I’m glad to know that the code has resolved your problem.
&$thisis outdated. Just do the name of the function. Noarray().Hi cubicinfinity,Yes, you are right! In updated PHP versions, you should not use the &$this syntax to specify the callback function for a class method. Instead, you should use the name of the function directly like this: add_action(‘woocommerce_before_checkout_form’, ‘ts_add_notice_free_shipping’);
Hi,
How to show the remaining cost when I have 2 free shipping methods (via post and via courier).
And I want to show the remaining for the courier cost because the minimum there is higher than via post.
Hi Avi, Please refer the code snippet in the heading “Show the Amount left while 2 Free shipping Methods are available” and it works exactly as per your requirement.
for me get_option(‘woocommerce_free_shipping_1_settings’) is always returning false
Hi Dante, Check out my response to this comment: https://www.tychesoftwares.com/display-the-remaining-cost-for-customer-to-avail-free-shipping-on-your-woocommerce-store/#comment-166922
You’re absolutely right. The woocommerce_free_shipping_1_settings parameter mentioned in the article is just an example. The actual parameter may vary based on your WooCommerce setup, and it corresponds to the specific free shipping method you are configuring.You can find your specific shipping parameter by right-clicking on the shipping method and inspecting the element in the developer tool in your browser.
Hi, please tell me get_option(‘woocommerce_free_shipping_1_settings’) not working in woocommerce 3.0+ ?
Hi. I had to look through my wp_options table to find the free shipping item. Mine was woocommerce_free_shipping_4_settings. The article above said “woocommerce_free_shipping_1_settings”
It looks like you will need to change that parameter to match what your site has.
Hi Poul, Please take a look at my previously provided response to this comment.
https://www.tychesoftwares.com/display-the-remaining-cost-for-customer-to-avail-free-shipping-on-your-woocommerce-store/#comment-217303
same question: https://www.tychesoftwares.com/display-the-remaining-cost-for-customer-to-avail-free-shipping-on-your-woocommerce-store/#comment-114371
thank you great service but you just supposed to free shipping settings for default value but there have could be different zones and different minimum threshold.
How can we handle with that situation?
Thank you
Hi Ahmet, It’s definitely possible to make the code work for different minimum threshold amounts in different shipping zones. By some configuration in WooCommerce settings and slight modification to the code mentioned in the blog post, it is possible. Please refer to this link for your reference.
https://prnt.sc/v0IgHyw9mMlI
https://prnt.sc/WRtei9wCrUgE
Great article Rashmi. I’ve tested the code with the WooCommerce Blocks plugin and it doesn’t appear to be compatible (presumably as a result of the vast changes to cart and checkout). I wonder whether there is any value in creating amending calls to support this (if it is possible)? I’d certainly find it useful!
Hi Dan, You’re correct that the changes above are not compatible with the WooCommerce Blocks plugin. We will pass this to our Development team & get back to you.
great thanks!
what if I always have a free standard shipping mode but then I want to ofer my clients free shipping at their door above a certain amount.
both set for free shipping .. is their a way to change the code so it only takes in account the free shipping as the second method?
Hi Lilu, the above specific requirement can be done possibly by creating another Shipping method such as ‘Free shipping at Door’ and setting the minimum amount to qualify for that shipping. Please refer to the screenshots below, as they align well with your requirements.
https://prnt.sc/QVKvMWo5Jzvu
https://prnt.sc/mgX-XrBHESIV
Thanks, looks good.
What if I have two shipping ID?
Eg. For State1 I set up a shipping zone, a flat rate and a free shipping from 100USD
For State2 I set up another shipping zone, flat rate, and free shipping from 150USD.
How should I adjust the code to show the different amounts? (And maybe different note…)
Hi Kovka, Please refer to the gist file on this GitHub link for your specific requirement – https://gist.github.com/saranyagokula/4c6e0911e0df116b6adc1e164c367c90
Hi, i’m trying to put the function before checkout but getting this error when trying to add the code to my theme functions.php, PLEASE help me 🙂
Uncaught Error: Using $this when not in object context in wp-content/themes/libreria-baldini-theme/functions.php:51
Stack trace:
#0 wp-settings.php(508): include()
#1 wp-config.php(92): require_once(‘/home/customer/…’)
#2 wp-load.php(37): require_once(‘/home/customer/…’)
#3 wp-admin/admin.php(34): require_once(‘/home/customer/…’)
#4 wp-admin/theme-editor.php(10): require_once(‘/home/customer/…’)
#5 {main}
thrown
Hello, just change the name of the checkout function and it will work, it worked for me.
Example: function wc_add_notice_free_shipping_checkout()
Hi Catalin, The code has been updated now that resolves the error regarding $this syntax. Please refer to the code snippet in the heading
“Show Amount Left for Free Shipping on Checkout Page”.
Awesome! It works perfectly, thanks!
Hi Sinful, Glad to hear that it works perfectly.
I copy/paste the Show Amount Left for Free Shipping on Checkout Page code, and it broken my website. I added on fuctions.php files and removed php tag, but it doesn’t work. Any idea ??
Hi Joe,
If you have added the code in the functions.php file then you will need to remove the array part from the add_action. Add this in your functions.php file:
add_action( ‘woocommerce_before_checkout_form’, ‘wc_add_notice_free_shipping’ );
The array is used when we add the action in a class consructor. I will make it clear in the blog.
I’ve tried both ways with or without array and not working either way. I used code snippet. Any other ideas? Your coding for removing all other shipping methods worked though.
Hi Rachel,
Can you tell me which code snippet you tried and what happened when you added it?
Hi thanks for this! I’ve gotten it working on the cart page but not the checkout page. I put the cart code in a Code Snippet. When I put the checkout page code in a snippet it said I couldn’t redeclare the function. I tried it with just the line you mentioned above but that didn’t do anything:
add_action( ‘woocommerce_before_checkout_form’, ‘wc_add_notice_free_shipping’ );
Thanks for your help.
change the function name it is the same for that on cart thatis why you get that message. either way it didn’t work for me
Hi Mark, Changing the name of the checkout function is indeed a common way to address the error you encountered. Try giving a unique name to the checkout function, so that you can avoid conflicts with the function name.
Do I have to copy the code in functions.php?
It’s not working there for me – thanks!
Hi Markus,
Yes, you will have to add this code in your active theme’s functions.php file. Can you show me the exact code you have added in the file?
If i put this on the cart page, i dont only the code:
cart->subtotal;
$remaining = $amount_for_free_shipping – $cart;
if( $amount_for_free_shipping > $cart ){
$notice = sprintf( “Add %s worth more products to get free shipping”, wc_price($remaining));
wc_print_notice( $notice , ‘notice’ );
}
}
?>
Someone help me pls (=
hello there, it doesn’t seem supporting ajax. so what would happen when cart is updated dynamically?
where is the code. just a dictation without example?
that just a theory which every one knows
Hi saad,
The github gists in the blog were not being displayed due to some issues. I have added code in the blog to explain the scenarios. Please do check them.
There is git code along with output, what else you need?