WooCommerce: Change the "no shipping method available" message to minimise customer confusion.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: WooCommerce - No shipping method message | |
Plugin URI: http://www.damiencarbery.com/2017/10/change-no-shipping-methods-available-message/ | |
Description: Change the "no shipping method available" message to minimise customer confusion. | |
Author: Damien Carbery | |
Version: 0.1 | |
*/ | |
add_filter( 'woocommerce_cart_no_shipping_available_html', 'nszm_no_shipping_available_html' ); | |
add_filter( 'woocommerce_no_shipping_available_html', 'nszm_no_shipping_available_html' ); | |
function nszm_no_shipping_available_html( $message ) { | |
$country = WC()->customer->get_shipping_country(); | |
if ( !empty( $country ) ) { | |
$all_countries = WC()->countries->get_countries(); | |
return sprintf( "Oops - we don't ship to %s.", $all_countries[ $country ] ); | |
} | |
return "Oops - we don't want your business."; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment