0

In the billing_fields.phtml there is

<?php
$billingFields['country_id'] = '
<div class="input-box input-country'.((in_array('country', $formErrors)) ? ' input-error' : '').'">
    <label for="billing:country_id">'.$this->__('Country').' <span class="required">*</span></label><br />
        '.$this->getCountryHtmlSelect('billing').'
</div>';
?>

I do have only one country and the select-tag $this->getCountryHtmlSelect('billing') with the rendered dropdown is not user friendly as it has no further options. I feel its misleading and obsolete. My question is:

How do I have to change the code above to show my default country in a simple (not editable) input field?

EDIT I came up with this after CBroes getCountryCollection hint

<?php
$countryCollection = $this->getCountryCollection();
foreach($countryCollection as $country) {
    $country_id = $country['country_id'];
    $countryName = Mage::getModel('directory/country')->load($country_id)->getName();
    $billingFields['country_id'] = '
    <div class="input-box input-country'.((in_array('country', $formErrors)) ? ' input-error' : '').'">
        <label for="billing:country_id">'.$this->__('Country').' </label><br />
            <input type="text" name="billing[country_id]" id="billing:country_id" class="input-text" value="'.$countryName.'" style="width: 83%" readonly="readonly" />
    </div>';
}
?>

The frontend looks fine. Even the backend recognizes the given value. Unfortunately the emails don't. The country field remains empty there.

What am I missing or how do I make this input legit so that magento-emails accept its value?

Damian
  • 27
  • 1
  • 1
  • 7
  • I’d say, try `getCountryCollection` instead, see what data structure that gives you … and then create your input field based on that yourself. Alternative: Transform the select to an input element client-side using JavaScript. – CBroe Mar 12 '14 at 11:10
  • I followed your idea and nearly got the solution. Thanks for that. Any idea how to pass the last obstacle? – Damian Mar 13 '14 at 15:03
  • What `name` attribute does the original select element have, and what `value` do its options send? (Look into the source code.) – CBroe Mar 13 '14 at 16:51
  • Yes! You saved the day. `value` was different. The select used _country id_. For the input value I went with _country name_. That's why it was missing in the order confirmation. Now I have to figure out how to display a different value (full country name instead of country code) to the user. I think I'll try that on my own now. Thank you very much! – Damian Mar 13 '14 at 18:09
  • Just insert an additional input `type=hidden` with the right name and value. (And leave out the name attribute for the other input field used for display.) – CBroe Mar 13 '14 at 18:17

0 Answers0