Help Wordpress

Help Wordpress

Wordpress can be fast. Very fast. Really :)

Woocommerce exclude states – free plugin

Woocommerce exclude states – free plugin

Once in a while becomes necessary to exclude states some U.S. states on the Woocommerce checkout page. The reasons may be different – for example, basically because store owner not want to deliver goods in the particular states. Or conversely – the store works only with a few specific U.S. states. In this article I will demonstrate few simple ways do it: via changes in code or via Woocommerce exclude states free plugin.

So, how add/exclude U.S. states in WooCommerce? I know about three ways, and I will describe each of them. And you yourself choose the best way.

Exclude U.S. states in WooCommerce via translation file

The list of the U.S. states located in /wp-content/plugins/woocommerce/i18n/states/US.php file.
However, must be remembered that this decision has a significant drawback. Once in a while need to update Woocommerce, and while you update Woo, you will must to edit this file again.

Exclude U.S. states in WooCommerce via functions.php

Just add in the functions.php file of your theme the following code snippet:

add_filter( 'woocommerce_states', 'custom_woocommerce_states' );
function custom_woocommerce_states( $states ) {
$states['XX'] = array(
'XX1' => 'State 1', 
'XX2' => 'State 2'
);
return $states;
}

 

However, must be remembered that this solution is also not without drawbacks:
1 – when you will update the template, you will have to re-edit the functions.php;
2 – if you decide to change the template, you have to make accordingly changes in functions.php of new template;

Woocommerce exclude states, free plugin

Given that drawbacks, I wrote a simple free plugin for Woocommerce. It allows you to add and exclude U.S. states. And compared to first and second ways, dont need any changes after update Woocommerce.

1. Upload the plugin files to the /wp-content/plugins/wa-edit-states directory;
2. Activate the plugin through the ‘Plugins’ screen in WordPress;
3. Use the WooCommerce -> Edit States List menu and enable or disable U.S. states;

As you can be seen on screenshots bellow, the plugin very easy to use, but if you have any questions – welcome to comments.

Backend screenshot - Woocommerce exclude states
Backend screenshot – Woocommerce exclude states

 

Frontend screenshot - Woocommerce exclude states
Frontend screenshot – Woocommerce exclude states

Woocommerce exclude states: download last version.

If you like this plugin, please click on one of the buttons to share it with your friends. Thank you!

Related posts:

Best image optimizer wordpress

Best image optimizer wordpress

For good speed results of your website without doubt, very important optimize images. Loading image 200 kb – is not the same as loading image 100 kb. Seems [...]
What’s New in WordPress 4.9

What’s New in WordPress 4.9

On November 15, 2017, WordPress Version 4.9, named “Tipton” in honor of jazz musician and band leader Billy Tipton, is available for download or update in your WordPress [...]
Use JS/CSS only where necessary

Use JS/CSS only where necessary

One of the methods of speeding up the speed of downloading WordPress sites – it is use additional external JS/CSS files only where necessary. I wrote about this [...]

Leave a Reply

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