
How to Add a New Country in the WooCommerce Default Country List
- September 2, 2016
- Leave a comment
Hooks in WordPress allows you to manipulate code without altering the core files. Similarly, action hook enables inserting custom code at various points whenever a particular hook is called.
If you use a hook to add or manipulate the existing code, add it to your custom code in your Theme‘s functions.php file. In this article, you will learn to add a missing country in WooCommerce default countries list without editing WooCommerce core files.
To add a new country in WooCommerce default countries list, WooCommerce provides a hook named as woocommerce_countires. Just add the following code in your Theme‘s functions.php file:
1 2 3 4 5 6 7 8 |
// hook to update WooCommerce countries list add_action('woocommerce_countries', 'add_new_country_woocommerce', 10, 1); // function to add new country function add_new_country_woocommerce( $country ) { $country['US'] = 'United State'; return $country; } |
User Comments