Waqas

I hope you enjoy reading this blog post. If you want my team to do WooCommerce Maintenance for you, click here.

How to restrict shipping countries list on Woocommerce checkout page?

In this tutorial we’ll learn how to restrict customers to place orders from specific countries only. Often store owners ship to only one or some countries and they don’t want customers to place orders from other countries. If you are having the same issue, don’t worry we can help you out there.

If you add some products to cart and proceed to checkout page you’ll see the default country dropdown in Woocommerce:

Our team at Themelocation is comprised of WordPress developers of high expertise

  • We can maintain, support and manage your single, or all your clients, website with dedication
  • Our skills are at your disposal.

Book a Call

woocommerce

Now we’ll reduce this to one country only. Let’s say a store owner will only want to display ‘Austarlia’ as shipping/billing country. Add the following lines of code at the end of your theme’s functions.php file.

function woo_override_checkout_fields( $fields ) { 

	$fields['shipping']['shipping_country'] = array(
		'type'      => 'select',
		'label'     => __('My New Country List', 'woocommerce'),
		'options' 	=> array('AU' => 'Australia')
	);

	return $fields; 
} 
add_filter( 'woocommerce_checkout_fields' , 'woo_override_checkout_fields' );

Now if you refresh the page you’ll see only australia as only country for shipping/billing addresses.

woocommerce5

Waqas

I hope you enjoy reading this blog post. If you want my team to do WooCommerce Maintenance for you, click here.

Leave a Comment

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