A customer required me to limit the available towns a customer can order from. So I thought it would be best to make the city field a select option. But Isotope does not seem to offer that option.
I've created a second checkout module with one change from the original. At a certain point inside function generateAddressWidgets, the function checks the field value for the country field. That's where I decided to go hacking and do the following:
Code:
if ($field['value'] == 'country')
{
$arrCountries = ($strAddressType == 'billing_address' ? $this->Isotope->Config->billing_countries : $this->Isotope->Config->shipping_countries);
$arrData['options'] = array_values(array_intersect($arrData['options'], $arrCountries));
$arrData['default'] = $this->Isotope->Config->country;
}
elseif ($field['value'] == 'city')
{
$objFields = $this->Database->prepare("SELECT * FROM tl_iso_allowed_places WHERE published = 1")
->execute();
if ($objFields->numRows)
{
unset($arrData['eval']['maxlength']);
$strClass = 'FormSelectMenu';
$arrData['inputType'] = 'select';
$arrData['eval']['includeBlankOption'] = true;
while ($objFields->next())
{
$arrData['options'][htmlspecialchars($objFields->city)] = htmlspecialchars($objFields->city);
$arrData['reference'][htmlspecialchars($objFields->city)] = $objFields->city;
}
}
}
This works perfectly so far, but is this a good method to solve this issue. Or does Isotope provide an even better way??
Bookmarks