/** * Renders the currency selector widget in "new order" page. */ public function render_currency_selector_widget() { $order_currency = $this->displayed_order_currency(); if (empty($order_currency)) { echo '<p>'; echo __('Set currency for this new order. It is recommended to choose ' . 'the order currency <b>before</b> adding the products, as changing ' . 'it later will not update the product prices.', AELIA_CS_PLUGIN_TEXTDOMAIN); echo '</p>'; echo '<p>'; echo __('<b>NOTE</b>: you can only select the currency <b>once</b>. If ' . 'you choose the wrong currency, please discard the order and ' . 'create a new one.', AELIA_CS_PLUGIN_TEXTDOMAIN); echo '</p>'; $currency_selector_options = array('title' => '', 'widget_type' => 'dropdown'); echo WC_Aelia_CurrencySwitcher_Widget::render_currency_selector($currency_selector_options); } else { // Prepare the text to use to display the order currency $order_currency_text = $order_currency; $currency_name = WC_Aelia_Currencies_Manager::get_currency_name($order_currency); // If a currency name is returned, append it to the code for displau. // If a currency name cannot be found, the method will return the currency // code itself. In such case, there would be no point in displaying the // code twice. if ($currency_name != $order_currency) { $order_currency_text .= ' - ' . $currency_name; } echo '<h4 class="order-currency">'; echo $order_currency_text; echo '</h4>'; } }
/** * Gets the active currency using the billing country. * * @return string */ protected function get_currency_by_billing_country() { $billing_country = $this->get_billing_country(); $currency = WC_Aelia_Currencies_Manager::factory()->get_country_currency($billing_country); // If currency used in the billing country is not enabled, take the default // used for GeoIP if (!$this->is_valid_currency($currency)) { $currency = self::settings()->default_geoip_currency(); } // Debug //var_dump("CURRENCY BY BILLING COUNTRY: $currency"); return $currency; }