diff --git a/docs/snippets/README.md b/docs/snippets/README.md index b7ad765ea5a..cbc55b83c14 100644 --- a/docs/snippets/README.md +++ b/docs/snippets/README.md @@ -4,4 +4,5 @@ Various code snippets you can add to your site to enable custom functionality: - [Add a message above the login / register form](./before-login--register-form.md) - [Change number of related products output](./number-of-products-per-row.md) -- [Unhook and remove WooCommerce emails](./unhook--remove-woocommerce-emails.md) \ No newline at end of file +- [Rename a country](./rename-a-country.md) +- [Unhook and remove WooCommerce emails](./unhook--remove-woocommerce-emails.md) diff --git a/docs/snippets/rename-a-country.md b/docs/snippets/rename-a-country.md new file mode 100644 index 00000000000..c455cf178d0 --- /dev/null +++ b/docs/snippets/rename-a-country.md @@ -0,0 +1,22 @@ +# Rename a country + +> This is a **Developer level** doc. If you are unfamiliar with code and resolving potential conflicts, select a [WooExpert or Developer](https://woocommerce.com/customizations/) for assistance. We are unable to provide support for customizations under our [Support Policy](http://www.woocommerce.com/support-policy/). + +Add this code to your child theme’s `functions.php` file or via a plugin that allows custom functions to be added, such as the [Code Snippets](https://wordpress.org/plugins/code-snippets/) plugin. Avoid adding custom code directly to your parent theme’s functions.php file, as this will be wiped entirely when you update the theme. + +```php +if ( ! function_exists( 'YOUR_PREFIX_rename_country' ) ) { + /** + * Rename a country + * + * @param array $countries Existing country names + * @return array $countries Updated country name(s) + */ + function YOUR_PREFIX_rename_country( $countries ) { + $countries['IE'] = 'Ireland'; + + return $countries; + } + add_filter( 'woocommerce_countries', 'YOUR_PREFIX_rename_country' ); +} +```