How to remove specific country in WooCommerce

2019-04-17 05:04发布

Can someone tell how can I remove the specific country from woocommerce. There is option in woocommerce that said selling locations with All countries and specific.

However I want to sell to all countries except the 1 country that is US for example! then how can I remove US from the countries list. As if I use "specific countries" option then I will have to add all the countries except the US which is longer process.

Is there any code you can help me with that I can put into functions of theme so that US country will not appear in the list of countries during checkout?

1条回答
叼着烟拽天下
2楼-- · 2019-04-17 05:56

Try this following snippet

function woo_remove_specific_country( $country ) 
{
   unset($country["US"]);
   return $country; 
}
add_filter( 'woocommerce_countries', 'woo_remove_specific_country', 10, 1 );

Reference http://www.boopathirajan.com/remove-specific-country-woocommerce-country-list/

查看更多
登录 后发表回答