At a WooCommerce talk in WordCamp Dublin I asked about changing a slightly confusing message. Instead of a translation plugin I changed it with code. I feel that it is less confusing now.
When he got to the checkout page on the demo site there was a lengthy message that there were no shipping methods to the specified shipping country. The site was set up to only ship to Ireland while his test customer’s shipping country was USA.
There are no shipping methods available. Please double check your address, or contact us if you need any help.
I felt that the message could confuse customers – it makes it seem like they have made a mistake. To reassure them, instead of blaming them, it would be worth rephrasing. I asked whether it was easy to change the message. Luminus suggested a translation plugin – a good recommendation for those not comfortable with code. But I love to code…
Search the source
I spent the rest of the day itching to get home to my laptop to search for the string and experiment with changing it.
I found the string in templates/cart/cart-shipping.php. Thankfully it was available to change via apply_filters(). The ternary operator code looks more confusing than it is – it’s there to allow for a different message when on the cart page or checkout page.
After a quick experiment to ensure that I read the ternary operator correctly I was able to change the message.
The message is displayed when WooCommerce knows the customer’s shipping details e.g. the customer is logged in and has previously placed an order or they have entered their details on the checkout page and have returned to cart page.
To help explain the reason for the message, I included the customer’s shipping country in the message.
I haven’t given the code a thorough test but it might be a starting point for others.
Before and After: