/**
  * Renders a "special" row on the exchange rates table, which contains the
  * settings for the base currency.
  *
  * @param string currency The currency to display on the row.
  * @param string exchange_rates An array of currency settings.
  * @param string base_field_id The base ID that will be assigned to the
  * fields in the row.
  * @param string base_field_id The base name that will be assigned to the
  * fields in the row.
  * @return string The HTML for the row.
  */
 protected function render_settings_for_base_currency($currency, $exchange_rates, $base_field_id, $base_field_name)
 {
     $currency_field_id = $this->group_field($currency, $base_field_id);
     $currency_field_name = $this->group_field($currency, $base_field_name);
     $html = '<tr>';
     // Output currency label
     $html .= '<td class="currency_name">';
     $html .= '<span>' . $this->_settings_controller->get_currency_description($currency) . '</span>';
     $html .= '</td>';
     $currency_settings = get_value($currency, $exchange_rates, array());
     $currency_settings = array_merge($this->_settings_controller->default_currency_settings(), $currency_settings);
     //var_dump($currency_settings);
     // Render exchange rate field
     $html .= '<td class="numeric">';
     $html .= '1';
     // Exchange rate for base currency is always 1
     $html .= '</td>';
     // Render "Set Manually" checkbox
     $html .= '<td>';
     $html .= '</td>';
     // Render exchange rate markup field
     $html .= '<td>';
     $html .= '</td>';
     // Render decimals field
     $default_currency_decimals = default_currency_decimals($currency, $this->_settings_controller->woocommerce_currency_decimals);
     $currency_decimals = get_value('decimals', $currency_settings, null);
     if (!is_numeric($currency_decimals)) {
         $currency_decimals = $default_currency_decimals;
     }
     $html .= '<td class="decimals">';
     $field_args = array('id' => $currency_field_id . '[decimals]', 'value' => $currency_decimals, 'attributes' => array('class' => 'numeric'));
     ob_start();
     $this->render_textbox($field_args);
     $field_html = ob_get_contents();
     ob_end_clean();
     $html .= $field_html;
     $html .= '</td>';
     // Render currency symbol field
     $currency_symbol = get_value('symbol', $currency_settings, get_woocommerce_currency_symbol($currency));
     $html .= '<td class="symbol">';
     $field_args = array('id' => $currency_field_id . '[symbol]', 'value' => $currency_symbol, 'attributes' => array('class' => 'text'));
     ob_start();
     $this->render_textbox($field_args);
     $field_html = ob_get_contents();
     ob_end_clean();
     $html .= $field_html;
     $html .= '</td>';
     $html .= '</tr>';
     return $html;
 }
 /**
  * Returns the number of decimals to be used for a specifc currency.
  *
  * @param string currency A currency code
  * @return array
  */
 public function get_currency_decimals($currency)
 {
     $default_decimals = default_currency_decimals($currency, $this->woocommerce_currency_decimals);
     // Decimals for the base currency are stored in WooCommerce settings
     if ($currency == $this->base_currency()) {
         return $this->woocommerce_currency_decimals;
     }
     $exchange_rates = $this->current_settings(self::FIELD_EXCHANGE_RATES);
     $currency_settings = get_value($currency, $exchange_rates);
     // If no decimals are configured, return default setting
     if (!is_array($currency_settings)) {
         return $default_decimals;
     }
     $decimals = get_value('decimals', $currency_settings, $default_decimals);
     return is_numeric($decimals) ? $decimals : $default_decimals;
 }