Advertisement
businessdad

How to add a custom list of states in WooCommerce

May 16th, 2015
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. /**
  2.  * Adds the UAE emirates to the list of states available at checkout.
  3.  *
  4.  * Need a consultation? Find us on Codeable: https://bit.ly/codeable_discount
  5.  *
  6.  * @param array states The list of states passed by WooCommerce.
  7.  * @return array The list of states, including the emirates for the UAE.
  8.  * @author Aelia <admin@aelia.co>
  9.  */
  10. add_filter('woocommerce_states', function($states) {
  11.     // Note: the keys of the array may not be correct. I used arbitrary values,
  12.     // to illustrate the concept
  13.     $states['AE'] = array(
  14.         'AD' => __('Abu Dhabi', 'your_text_domain'),
  15.         'DB' => __('Dubai', 'your_text_domain'),
  16.         'SH' => __('Sharjah', 'your_text_domain'),
  17.         'AJ' => __('Ajman', 'your_text_domain'),
  18.         'FJ' => __('Fujairah', 'your_text_domain'),
  19.         'RS' => __('Ras al-Khaimah', 'your_text_domain'),
  20.         'UM' => __('Umm al-Qaiwain', 'your_text_domain'),
  21.     );
  22.     return $states;
  23. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement