Support » Plugin: New Zealand Shipping Zones for WooCommerce » Exclude RD deliveries

  • Resolved danielhay


    Hey there, Will this plugin allow us to disable shipping to rural delivery as an and option?


Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Daniel Shaw


    Hello Dan,

    Sure, there is a way to achieve this using this plugin as a starting point.

    First, make sure there’s no shipping method assigned for either of the rural shipping zones you’ll see at WooCommerce > Settings > Shipping (these zones are generated when the plugin is activated). At this point, you’ll see if you try to add a rural postcode in the shipping calculator WooCommerce will display a message, “No shipping options were found”.

    Next, add the following code to your theme’s functions.php file:

     * Check if rural postcode and display message.
     * @return string
    function chthnc_set_message_shipping_not_available() {
      if ( ! is_admin() ) {
        $shipping_packages = WC()->cart->get_shipping_packages();
        $shipping_zone     = wc_get_shipping_zone( reset( $shipping_packages ) );
        $zone_name         = $shipping_zone->get_zone_name();
        if ( 'North Island (Rural)' === $zone_name || 'South Island (Rural)' === $zone_name ) {
          return __( 'Sorry, we do not ship to rural addresses.' );
    add_filter( 'woocommerce_no_shipping_available_html', 'chthnc_set_message_shipping_not_available' );
    add_filter( 'woocommerce_cart_no_shipping_available_html', 'chthnc_set_message_shipping_not_available' );

    This little script will do a couple of things:

    1. Check if the selected shipping zone is a rural one
    2. Replace the generic WooCommerce message with a custom message, “Sorry, we do not ship to rural addresses.”

    As an extra step, it’s worth making your postcode form field a required field (if not already), to ensure a customer doesn’t try to slip through a rural address.

    I hope this helps.

    Plugin Author Daniel Shaw


    I’m going to mark this topic as resolved. Please feel free to create a new thread if you have further questions 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude RD deliveries’ is closed to new replies.