Advertisement
businessdad

Aelia Currency Switcher - Custom currency selector dropdown

Oct 12th, 2016
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. /**
  2.  * Aelia Currency Switcher - Sample of custom currency selector dropdown.
  3.  *
  4.  * @author Aelia <support@aelia.co>
  5.  * Need a consultation? Find us on Codeable: https://bit.ly/codeable_discount
  6.  */
  7. // Get a list of the available currencies
  8. $currencies =  apply_filters('wc_aelia_cs_enabled_currencies', array(get_option('woocommerce_currency')));
  9. // Get the active currency. The Aelia Currency Switcher returns the correct one automatically
  10. $active_currency = get_woocommerce_currency();
  11.  
  12. echo '<select id="aelia_cs_currencies" name="aelia_cs_currency">';
  13. foreach($currencies as $currency_code => $currency_name) {
  14.     $selected_attr = '';
  15.     if($currency_code === $active_currency) {
  16.         $selected_attr = 'selected="selected"';
  17.     }
  18.     echo '<option value="' . $currency_code . '" ' . $selected_attr . '>' . $currency_name. '</option>';
  19. }
  20. echo '</select>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement