コード例 #1
0
/**
 * Check Currency Rate
 * 
 * Handles to check currency rate
 * 
 * @package Easy Digital Downloads - Currency Converter
 * @since 1.0.0
 **/
function edd_currency_get_custom_currency_rate($currency_code)
{
    $currency_rate = '';
    if (!empty($currency_code)) {
        //get currency list
        $currencies = edd_currency_get_list();
        foreach ($currencies as $currency) {
            if (isset($currency['code']) && $currency['code'] == $currency_code) {
                $currency_rate = $currency['custom_rate'];
                break;
            }
        }
    }
    return $currency_rate;
}
コード例 #2
0
 /**
  * Register Settings
  * 
  * Handels to add settings in settings page
  * 
  * @package Easy Digital Downloads - Currency Converter
  * @since 1.0.0
  */
 public function edd_currency_settings($settings)
 {
     global $edd_options;
     $success_message = '';
     //create currency page option default
     $currency_page = get_option('edd_currency_select_currency_page');
     //default selected currency page
     $selected_page_id = isset($currency_page) ? $currency_page : '';
     // Display success message when click Apply Currency extensions settings
     if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'apply_currency' && isset($_GET['success_count'])) {
         $success_count = $_GET['success_count'];
         $success_message = '<div class="updated" id="message"><p><strong>' . sprintf(__('%d order(s) updated.', 'eddcurrency'), $success_count) . '</strong></p></div>';
     }
     $pages = get_pages();
     $pages_options = array('' => __('--Select Currency Page--', 'eddcurrency'));
     // Blank option
     if ($pages) {
         foreach ($pages as $page) {
             $pages_options[$page->ID] = $page->post_title;
         }
     }
     //currencies for base currencies
     $base_currencies = array('' => __('--Select Base Currency--', 'eddcurrency'));
     $currencies = edd_currency_get_list();
     if (!empty($currencies)) {
         foreach ($currencies as $curr) {
             $base_currencies[$curr['code']] = $curr['label'];
         }
     }
     $edd_currency_settings = array(array('id' => 'edd_currency_settings', 'name' => $success_message . '<strong>' . __('Currency Converter Settings', 'eddcurrency') . '</strong>', 'desc' => __('Configure Currency And Rewards Settings', 'eddcurrency'), 'type' => 'header'), array('id' => 'edd_currency_general_settings', 'name' => '<strong>' . __('General Options', 'eddcurrency') . '</strong>', 'type' => 'header'), array('id' => 'exchange_rates_method', 'name' => __('Exchange Rates Method', 'eddcurrency'), 'desc' => '<p class="description">' . __('Choose exchange rates method. If you choose', 'eddcurrency') . ' "' . __('both', 'eddcurrency') . '" ' . __('rates then it will take custom rates, if custom rate is empty then it will consider open exchange rates. If both are empty it won\'t convert currency on front side.', 'eddcurrency') . '</p>', 'type' => 'radio', 'options' => array('open_exchange' => __('Open Exchange Rates', 'eddcurrency'), 'custom_rates' => __('Custom Rates', 'eddcurrency'), 'both_rates' => __('Both Rates ( Open Exchange Rates and Custom Rates )', 'eddcurrency'))), array('id' => 'select_currency', 'name' => __('Select Currency Page', 'eddcurrency'), 'desc' => '<p class="description">' . __('Shortcode to place on page:', 'eddcurrency') . ' <code>[edd_select_currency]</code>' . '</p>', 'type' => 'select', 'options' => $pages_options), array('id' => 'replace_currency_code', 'name' => __('Replace Currency symbol', 'eddcurrency'), 'desc' => '<p class="description">' . __('Replace the Currency symbol with Currency code.', 'eddcurrency') . '</p>', 'type' => 'checkbox'), array('id' => 'append_code', 'name' => __('Append Currency Code', 'eddcurrency'), 'desc' => '<p class="description">' . __('Appends currency code to prices.', 'eddcurrency') . '</p>', 'type' => 'checkbox'), array('id' => 'curr_code_position', 'name' => __('Currency Code Position', 'eddcurrency'), 'desc' => '<p class="description">' . __('Choose the location of the currency code, when append currency code is enabled.', 'eddcurrency') . '</p>', 'type' => 'select', 'options' => array('before' => __('Before - USD 10', 'eddcurrency'), 'after' => __('After - 10 USD', 'eddcurrency'))), array('id' => 'replace_base_currency', 'name' => __('Replace Base Currency', 'eddcurrency'), 'desc' => '<p class="description">' . __('Replaces base prices with converted prices (alternatively the converted price will be shown beside the base price).', 'eddcurrency') . '</p>', 'type' => 'checkbox'), array('id' => 'display_cart_notification', 'name' => __('Display Cart Notification', 'eddcurrency'), 'desc' => '<p class="description">' . __('If the customer saved a currency that is different from the base EDD currency, notify the customer on the cart page that all orders are processed in the base EDD currency.', 'eddcurrency') . '</p>', 'type' => 'checkbox'), array('id' => 'curr_base_currency', 'name' => __('Base Currency', 'eddcurrency'), 'desc' => '<p class="description">' . __('Choose base currency. if you set base currency different then the one set in general settings then it would show by default price in both currencies.', 'eddcurrency') . '<p>', 'type' => 'select', 'options' => $base_currencies), array('id' => 'edd_currency_exchange_rate_settings', 'name' => '<strong>' . __('Open Exchange Rates Options', 'eddcurrency') . '</strong>', 'type' => 'header'), array('id' => 'exchange_app_id', 'name' => __('App ID', 'eddcurrency'), 'desc' => '<p class="description">' . __('Enter open exchange rate APP ID, changing the APP ID will clear the cache.', 'eddcurrency') . '<p>', 'type' => 'text', 'size' => 'regular'), array('id' => 'exchange_rates_cache', 'name' => __('Cache Length', 'eddcurrency'), 'desc' => '<p class="description">' . __('Length of time in minutes to cache retrieved exchange rates.', 'eddcurrency') . '</p>', 'type' => 'text', 'size' => 'regular'), array('id' => 'edd_currency_detection_settings', 'name' => '<strong>' . __('Detection Options', 'eddcurrency') . '</strong>', 'type' => 'header'), array('id' => 'currency_detection', 'name' => __('Enable Currency Detection', 'eddcurrency'), 'desc' => '<p class="description">' . __('Check this box, if you want to allow to automatic detect currency and replace it based on customer IP address.', 'eddcurrency') . '</p>', 'type' => 'checkbox'), array('id' => 'prompt_user_detection', 'name' => __('Prompt User', 'eddcurrency'), 'desc' => '<p class="description">' . __('Check this box, if you want to prompt the customer if they want to save their detected currency. If unchecked, the detected currency will be automatically saved for the customer.', 'eddcurrency') . '</p>', 'type' => 'checkbox', 'std' => 'no'));
     return array_merge($settings, $edd_currency_settings);
 }