businessdad icon

Aelia Currency Switcher - Custom currency selector dropdown

businessdad | PRO | 10/12/16 08:18:18 AM UTC | 0 ⭐ | 930 👁️ | Never ⏰ | []
PHP |

850 B

|

None

|

0 👍

/

0 👎

/**
 * Aelia Currency Switcher - Sample of custom currency selector dropdown.
 *
 * @author Aelia <[email protected]>
 * Need a consultation? Find us on Codeable: https://bit.ly/codeable_discount
 */
// Get a list of the available currencies
$currencies =  apply_filters('wc_aelia_cs_enabled_currencies', array(get_option('woocommerce_currency')));
// Get the active currency. The Aelia Currency Switcher returns the correct one automatically
$active_currency = get_woocommerce_currency();
 
echo '<select id="aelia_cs_currencies" name="aelia_cs_currency">';
foreach($currencies as $currency_code => $currency_name) {
    $selected_attr = '';
    if($currency_code === $active_currency) {
        $selected_attr = 'selected="selected"';
    }
    echo '<option value="' . $currency_code . '" ' . $selected_attr . '>' . $currency_name. '</option>';
}
echo '</select>';

Comments