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.
Additionally, you can also show custom messages below each shipping method to display delivery day range based on shipping country in WooCommerce cart.