Skip to content

zc158: Use built-in function to gather country-specific zones #333

@proseLA

Description

@proseLA

hi cindy,

this section of code:

public function getCountriesZonesJavascript()
{
global $db;
$countries = $db->Execute(
"SELECT DISTINCT zone_country_id
FROM " . TABLE_ZONES . "
INNER JOIN " . TABLE_COUNTRIES . "
ON countries_id = zone_country_id
AND status = 1
ORDER BY zone_country_id"
);
$c2z = [];
foreach ($countries as $country) {
$current_country_id = $country['zone_country_id'];
$c2z[$current_country_id] = [];
$states = zen_get_country_zones($current_country_id);
foreach ($states as $state) {
$c2z[$current_country_id][$state['id']] = $state['text'];
}
}
$output_string = 'var c2z = \'' . addslashes(json_encode($c2z)) . '\';' . PHP_EOL;
return $output_string;
}

looks very much like this section:

https://github.com/zencart/zencart/blob/2160f2936ce2f466495a4acdfed65e826588adbc/includes/templates/template_default/jscript/zen_addr_pulldowns.php#L26-L54

i think if we could move the ZC to a function (the horror), we could then make use of it here.

thoughts?

i would not be opposed to doing the PR on the zc if you think we can make use of it here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions