Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
proseLA opened this issue May 20, 2022 · 1 comment
Open

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

proseLA opened this issue May 20, 2022 · 1 comment
Labels
change zc158 Updates for zc158
Milestone

Comments

@proseLA
Copy link
Contributor

proseLA commented May 20, 2022

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.

@lat9 lat9 changed the title potential refactor.. zc158: Use built-in function to gather country-specific zones May 26, 2022
@lat9 lat9 added change zc158 Updates for zc158 labels May 26, 2022
@lat9
Copy link
Owner

lat9 commented May 26, 2022

Using a base zen-cart function is the way to go, but since that function's present in zc158 and later, I'd prefer to wait until such time that OPC is updated for zc158 and later.

@lat9 lat9 added this to the v2.5.0 milestone Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change zc158 Updates for zc158
Projects
None yet
Development

No branches or pull requests

2 participants