Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Display Custom Message Based on Shipping Zone in WooCommerce?

Worried about orders falling through the cracks because of inaccurate shipping costs? This code snippet has your back! By implementing it, you’ll automatically inform customers outside your regular shipping zone that they need to contact you for an accurate shipping cost.

add_action( 'woocommerce_cart_totals_after_shipping' , 'ts_out_of_zone_shipping_notice' );
add_action( 'woocommerce_review_order_after_shipping' , 'ts_out_of_zone_shipping_notice' );
function ts_out_of_zone_shipping_notice() {
    // HERE DEFINE YOUR SHIPPING COUNTRY NAMES
    $targeted_country_names = array("IN"); // 

    // Get the customer shipping country
    $shipping_country    = WC()->customer->get_shipping_country();
    
    if( !in_array( $shipping_country, $targeted_country_names ) ){
        echo '<tr class="shipping"><td colspan="2" style="text-align:center">You are outside of our regular shipping zone. Please <a href="../contact/">contact us</a> with your address so we can get an accurate cost to ship.</td></tr>';
    }
}

Output

By implementing the below code, you’ll automatically inform customers outside your regular shipping zone that they need to contact you for an accurate shipping cost.

How to Display Custom Message Based on Shipping Zone in WooCommerce?

Additionally, you can also show custom messages below each shipping method to display delivery day range based on shipping country in WooCommerce cart.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Newest
Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x