Skip to content

Instantly share code, notes, and snippets.

@damiencarbery
Created October 16, 2017 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damiencarbery/0251fe73654bd36efdc5ad0f80a26f9f to your computer and use it in GitHub Desktop.
Save damiencarbery/0251fe73654bd36efdc5ad0f80a26f9f to your computer and use it in GitHub Desktop.
WooCommerce: Change the "no shipping method available" message to minimise customer confusion.
<?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