Create location restriction in woocommerce

Swadhin IT Solutions: The Best IT Company In Bhubaneswar
July 4, 2018
How do I create custom WooCommerce shop page?
July 7, 2018

To Create a location restrict based woocommerce website , you need to use some code in function file.


your code will be as follow

add_action( ‘woocommerce_cart_coupon’, array(&$this, ‘new_woocommerce_cart_coupon’), 10, 0 );
add_action( ‘template_redirect’, array(&$this, ‘new_post_code_cart_button_handler’) );

public function new_woocommerce_cart_coupon() {
<br/><br/><p>Enter your postcode</p><label for=”post_code”>Post Code</label> <input type=”text” name=”post_code” class=”input-text” id=”post_code” value=”” /> <input type=”submit” class=”button” name=”apply_post_code” value=”Check Post Code” />

public function new_post_code_cart_button_handler() {
if( is_cart() && isset( $_POST[‘post_code’] ) && $_SERVER[‘REQUEST_METHOD’] == “POST” && !empty( $_POST[‘post_code’] ) ) {
//validate post code here


Put the zip codes you want to ship.

Leave a Reply

Your email address will not be published. Required fields are marked *