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

How to Add Message for Out-Of-Delivery Area Warning in WooCommerce Cart?

If you need to inform your customers that you are unable to deliver a product for a particular area, use the following snippet.

add_action('woocommerce_after_cart', 'ts_check_selected_state',10,2);

function ts_check_selected_state() {
 // Get the selected state
    $selected_state = WC()->customer->get_shipping_state();

    // Check for unavailable states (adjust the array as needed)
    $unavailable_states = array('MP', 'KA', 'TN'); // Example list of unavailable states

    if (in_array($selected_state, $unavailable_states)) {
        wc_add_notice(sprintf(__('Delivery to %s is not available at the moment.', 'your-text-domain'), $selected_state), 'error');
    }
}

Output

The below output shows the warning area regarding the delivery of a product that cannot be done in a particular state.

How to Add Message for Out-Of-Delivery Area Warning in WooCommerce Cart? - Tyche Softwares

Additionally, you can also customize to display delivery day range based on shipping country in WooCommerce cart so that you can clearly inform customers about any changes in delivery estimates and ensure that your fulfillment processes match the customized delivery day ranges.

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
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible.

Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

By using our site, you acknowledge that you have read and understood our Privacy Policy and Terms & Conditions.