• Resolved jjbte

    (@jjbte)


    Before updating WooCommerce, any $0-cost shipping methods in my cart displayed “Free” (or maybe $0.00, but they definitely displayed something to indicate cost) after the shipping method name. Now they display nothing.

    I have set up a shipping zone with zip codes and it has the Free Shipping method associated with it. I also use the WooCommerce USPS Shipping extension by WooThemes. I updated the extension a few days ago (before I updated WooCommerce to 2.6.1) and “Free” was still displaying after the extension update. The “Free” display went away only after I updated to WooCommerce 2.6.1.

    Did something change regarding shipping cost display when the cost is $0? If so, could it be changed back? I find that some customers get upset if things aren’t explicitly spelled out for them. Having a cost display next to other methods and not next to the free methods might be upsetting to some.

    https://wordpress.org/plugins/woocommerce/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    Not the same. Just add ‘free’ to the method name. Thats obvious no?

    You are right Mike, my mistake 🙂

    Thread Starter jjbte

    (@jjbte)

    Yes, Mike, that will work for methods created for shipping zones.

    However, what about other rates that are free based on various parameters? I wrote a function that utilizes the woocommerce_package_rates filter to discount shipping rates when a customer’s subtotal is $50 or higher. In my store, USPS Media Mail is $0 under these circumstances.

    Before WooCommerce 2.6, Media Mail displayed a cost of “FREE” after the method name. Now it just displays nothing when the subtotal meets the requirements for free Media Mail shipping.

    If this change was made because you assumed users could just add “Free” to their shipping zone method names, then you should have taken into account that there are other shipping plugins/extensions available, and that users can utilize the woocommerce_package_rates filter to adjust shipping costs.

    So I have to ask, why was it necessary to make this change? And can you please change it back?

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    Because to be frank, showing “FREE SHIPPING (FREE)” is just silly. No cost should show no price. If you want it back, the method name is filterable.

    Thread Starter jjbte

    (@jjbte)

    Something like “Local Delivery (FREE)” or “Local Delivery ($0.00)” would not be silly, though. You’re making it a requirement for users to call their methods “Free” something.

    And again, that’s just for shipping zone methods. Anyone using extensions (including extensions purchased from WooThemes) must know how to program and how to use WP filters in order to alter their method names, etc. That’s not a big problem for me, but it does mean I have to spend extra time on this now. And users who don’t know how to program are out of luck.

    It’s obvious you’re annoyed with me, but I just don’t see why this change was necessary, and I don’t understand why my discussion about extensions was completely disregarded. The new Shipping Zones functionality is great, but it’s not going to be all things to all users and shipping extensions will likely still be necessary for many stores.

    Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    And users who don’t know how to program are out of luck.

    Unless they are one of the many who don’t want to show “Free Shipping (FREE)” at checkout, in which case, they are in luck.

    I don’t think Mike is annoyed necessarily, he just doesn’t want to argue over this. There was a reason it was changed, and it has been mentioned. You are thinking only about your particular need and use-case.

    Consider these three situations:

    1. Store owner has a “TBD” shipping rate and will determine the cost after the order has gone through and then bill the customer. With the way things were, the rate name would be “TBD (Free)”, which is very misleading. Said store owner would need to filter the name to remove the free part.

    2. Store owner number two is offering Free Shipping and doesn’t want the rate to say “Free Shipping (Free)”. Said store owner would need to also filter the name.

    3. Another store owner doesn’t like the work “Free”, and wanted rates to say either ($0.00) after them or nothing instead. They would also need to have custom code.

    So as you can see, removing it altogether by default fits a much wider use case. Just because if makes sense on your site does not mean it needs to be there by default for all sites.

    I don’t understand why my discussion about extensions was completely disregarded.

    If an extension is using the woocommerce_package_rates filter to adjust shipping rates, then why can it not also use a filter to add (Free) at the end of the name?

    Again, not ignoring you or being annoyed. But please look at both sides of the coin instead of only focused on your needs.

    Thread Starter jjbte

    (@jjbte)

    Thank you for your input, Caleb, although I’m not in total agreement with your assessment. For instance, Shipping Zone methods can be named whatever the user wishes, so it is not absolutely necessary to include “Free” in the name.

    And I am not “thinking only about [my] particular need and use-case.” I know there are other store owners who wish to manipulate their shipping rates because I came across their questions and helpful suggestions when I was looking to do so myself. Many online stores offer free/discounted shipping for purchases above a certain amount. I just shopped at a store a few days ago that offered a free shipping method (with “FREE” to the right of its name), and faster methods with costs > $0. So I hardly think I’m the only store owner on the planet looking to do something similar.

    I am using the WooCommerce USPS Shipping extension (purchased from WooThemes) and I wrote a function that uses the woocommerce_package_rates filter to change the USPS Media Mail rate to $0 when the subtotal is $50 or higher. Yes, most customers should realize that Media Mail with nothing next to it (as opposed to other methods with dollar amounts next to them) means it’s free. But over the years I’ve occasionally received questions from customers who apparently could not read what was right in front of them, or just couldn’t understand something that other customers were able to figure out with no problem. No one wants to lose a sale simply because something wasn’t fully spelled out for a persnickety customer.

    Anyway, I went through the WooCommerce code and found the proper filter to use in order to add “FREE” when a rate is $0. I’m sharing it below for anyone with circumstances similar to mine. I chose to go with all-caps FREE, but just remove the strtoupper function if you’d rather display “Free.”

    To simply add “FREE” after all $0-cost method names, add the following to your functions.php file:

    add_filter('woocommerce_cart_shipping_method_full_label', 'add_free_label', 10, 2);
    function add_free_label($label, $method) {
    	if ($method->cost == 0) {
    		$label .= ': '.strtoupper(__( 'Free', 'woocommerce' ));
    	}
    	return $label;
    }

    If you need to exclude a specific method (for instance, if it already has “Free” in its name), use this code instead (replace ‘your_shipping_name_id’ with the id of your method)*:

    add_filter('woocommerce_cart_shipping_method_full_label', 'add_free_label', 10, 2);
    function add_free_label($label, $method) {
    	if ($method->cost == 0 && $method->id !== 'your_shipping_name_id') {
    		$label .= ': '.strtoupper(__( 'Free', 'woocommerce' ));
    	}
    	return $label;
    }

    *Methods added to Shipping Zones are ID’d differently than other methods. The format is method_id:instance_id. For example, the first addition of the Free Shipping method to a Shipping Zone will have “free_shipping:1” as its ID. If you have access to your WP MySQL database, you can figure out the method_id and instance_id by looking at the woocommerce_shipping_zone_methods table.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    ^ perfect. And since you were only affected by this by filtering in the first place, it’s in your ability to add the above.

    We need to cover the most popular use cases – removing the hardcoded value makes it the most flexible, and makes it possible to do with the core methods without code.

    @jjbte Thanks for including that code! I was looking all over for something & found yours to do what I wanted (I just want it to say Free), but the issue I’m having is that it displays as I want on the checkout page, but once I’ve checked out, it does not say the same thing within the My Accounts page and the receipt/email that is sent out to customers. Do you happen to know how I can make it so the change is universally applied?

    Thanks a ton!!

    Thread Starter jjbte

    (@jjbte)

    Hi, veggiebunches. This code adds “FREE via” before the shipping method name in the order receipt, emails, My Account, etc.

    add_filter('woocommerce_order_shipping_to_display', 'display_free');
    function display_free($shipping) {
    	if (WC()->order_shipping == 0) {
    		$shipping = strtoupper(__( 'Free', 'woocommerce' )).apply_filters( 'woocommerce_order_shipping_to_display_shipped_via', '&nbsp;<small class="shipped_via">' . sprintf( __( 'via %s', 'woocommerce' ), $shipping ) . '</small>');
    	}
    	return $shipping;
    }

    If you need to exclude a particular method, you’ll need to check for its method name (the name displayed in your Admin area, not the method ID):

    add_filter('woocommerce_order_shipping_to_display', 'display_free');
    function display_free($shipping) {
    	if (WC()->order_shipping == 0 && $shipping != 'My Excluded Method Name') {
    		$shipping = strtoupper(__( 'Free', 'woocommerce' )).apply_filters( 'woocommerce_order_shipping_to_display_shipped_via', '&nbsp;<small class="shipped_via">' . sprintf( __( 'via %s', 'woocommerce' ), $shipping ) . '</small>');
    	}
    	return $shipping;
    }

    One caveat with this code… It is possible (although unlikely) for the shipping name to be a translation of “Free!” This is based on the behavior of the get_shipping_to_display() function in woocommerce/includes/abstracts/abstract-wc-order.php. This can only happen when the shipping cost is 0 and there is no shipping method retrieved. If that were to happen, your shipping line would read “FREE via Free!” or the applicable translation.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘$0 Shipping Methods no Longer Display "Free" Next to Method Name’ is closed to new replies.