Today’s Ask Jilt question comes from our comments section! Carla asks:
I’m flummoxed as to how to use the shipping zones to reflect that SOME of my products have free shipping…I’ve set up a shipping class that doesn’t charge a shipping fee but then the cart displays ‘Flat Rate’ rather than ‘Free Shipping.’ Granted, there’s no amount shown, but I don’t want my customers to wonder about whether they’re getting free shipping or not.
This is a great question, as this changed with the latest WooCommerce.
First, we’ll talk about how Carla has this set up. Because the free shipping is per-product and not by order amount or coupon, the set up with WooCommerce 2.6 is a bit weird. To achieve a set up in which some products are shipped for free, you’ll need to take a few steps:
- Set up a Shipping Class under WooCommerce > Shipping > Shipping Classes called “Free Shipping” or whatever name you’d like to indicate this class is for items with no shipping charge.
- For any products that should not charge shipping, add them to this shipping class.
- When you add a method to your shipping zone, set the method fee to $0. Use $0 for your free shipping item class as well, and then set the rate you want for the “No shipping class” rate.
Here’s how this will behave:
- If the cart only contains items in the “Free shipping” class, then this method’s cost will be $0.
- If the cart only contains items that are not in a shipping class, the method’s cost will be whatever you’ve set for “No shipping class”.
- If the cart contains both items in this shipping class and without a shipping class (or with another class), then the shipping method cost will be what you’ve set for “No shipping class”. (Unless of course you have costs for other classes and they’re present, in which case they’re all added up.)
Now here’s where Carla’s question comes into play — let’s talk about the WooCommerce free shipping label. If the item in the cart has free shipping, this isn’t necessarily obvious to the customer, as it doesn’t say “Free” anywhere:
We can add a bit of custom code here to change the label if the method’s cost is $0 (so long as you know how to add custom code to your site):
<?php // only copy this line if needed
/**
* Changes the shipping label if the cost is $0
*
* @param string $label the shipping method label
* @param obj $method \WC_Shipping_Rate
* @return string - new shipping method label
*/
function sww_wc_free_shipping_label( $label, $method ) {
if ( 0 == $method->cost ) {
$label = 'Free shipping!';
}
return $label;
}
add_filter( 'woocommerce_cart_shipping_method_full_label', 'sww_wc_free_shipping_label', 10, 2 );
Now the method’s label will be replaced with “Free shipping!” if it has no cost, or will just use the regular label if the cost is not free.
Hope this helps Carla and anyone else who’s run into this issue with the WooCommerce free shipping label in WC 2.6!
I’ve also submitted a pull request that would restore the previous behavior of adding “(Free)” to the label, so keep an eye on it. If it’s merged, the next version of WooCommerce will probably adjust this.
Hi Beka!
I’m so happy to be doing my small part to clarify all the permutations of shipping zones!
But I’m sad to say that I’m still flummoxed. After much testing, I realized that your lovely setup suggestions for my ‘free shipping’ products wasn’t working because the products are variable. Works quite well for simple products, but not the variable ones. Tried setting the shipping class both as a parent and with the specific variations. Still no joy.
In the meantime, I did find a plugin, ‘WooCommerce Advanced Free Shipping,’ that at least allowed me to show free shipping for the variable product, although the display in the cart is still confusing (shows ‘Flat rate’ as well as ‘Free Shipping’).
Next up, I’ll try this code snippet to see if I can get the cart display the way I want it.
Thanks again for all your input!