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

How to Make City Required in WooCommerce Shipping Calculator?

If you need to make the city field a required field in the shipping calculator, you can use the following code snippet to customize the shipping calculator fields. Before you implement this code, you should edit the /wp-content/plugins/woocommerce/templates/cart/shipping-calculator.php file and add this code at line 78. Once you’ve made the changes, save the template file.

<p class="form-row form-row-wide" id="calc_shipping_city_field">
    <label for="calc_shipping_city" class="screen-reader-text">City:</label>
    <input 
        type="text" 
        class="input-text" 
        required 
        value="CurrentShippingCity" 
        placeholder="City" 
        name="calc_shipping_city" 
        id="calc_shipping_city" 
    />
</p>

Output

The below output shows that the city input field is required in the WooCommerce shipping calculator.

How to Make City Required in WooCommerce Shipping Calculator?

Depending on your store’s preference you can choose to make any fields optional or mandatory. Similar to the above customization you can also make fields mandatory or optional on the WooCommerce checkout page.

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.