Ban Russia From the Checkout in WooCommerce

yellow and black caution tape

The Russian invasion of Ukraine of February 2022 is currently affecting everyone in the world, most of all Ukrainian people, of course.

As individuals, there’s not much that we can do other than donating to the cause and helping those in need.

If you are a shop owner currently selling to Russia and want to align with the sanctions of NATO and all the other countries, in your small reality, you can ban Russia from your WooCommerce store.

How can you do that? Let me explain!

If you are selling to specific countries only and Russia is one of them, you can remove it by going to WooCommerce > Settings > General > General options > Selling location(s) > Select – Sell to Specific Countries.

If you are selling to all countries, you can ban Russia from the list on your Checkout page with a PHP snippet. Add this code to your wp-content/themes/your-child-theme/functions.php file:

add_filter( 'woocommerce_countries_allowed_countries', 'wc_ban_russia' );
function wc_ban_russia( $countries ) {
if ( isset( $countries['RU'] ) ) {
unset( $countries['RU'] );
}
return $countries;
}
view raw functions.php hosted with ❤ by GitHub

It might not seem much, but every little bit helps towards stopping this war against innocent people.


More Posts That You Might Like…


Leave a Reply

Categories

Newsletter

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Blog at WordPress.com.

%d bloggers like this: