[MOD] GeoZone - Add All Countries Button
84 posts
• Page 1 of 5 • 1, 2, 3, 4, 5
[MOD] GeoZone - Add All Countries Button
For those who want to make a "Rest of the world" zone, that has all zones except a few, I made this button that will allow you to easily do this. I Created a new javascript button next to "Add Geo Zone" called "Add All Countries".
This basically adds a new geozone for each country and autoselects each individual country. Then you can simply remove the countries you don't want to be part of that geozone and save.
1. EDIT: admin/view/template/localisation/geo_zone_form.tpl
2. FIND:
3. AFTER, ADD:
4. AT THE BOTTOM OF THAT FILE, ADD:
Now insert a new GeoZone. Click the "Add All Countries" button... (wait like 5-10secs as it is very system intensive) Then you should see every country added. Remove the ones you don't want.
This basically adds a new geozone for each country and autoselects each individual country. Then you can simply remove the countries you don't want to be part of that geozone and save.
1. EDIT: admin/view/template/localisation/geo_zone_form.tpl
2. FIND:
- Code: Select all
<a onclick="addGeoZone();" class="button"><span class="button_left button_insert"></span><span class="button_middle"><?php echo $button_add_geo_zone; ?></span><span class="button_right"></span></a>
3. AFTER, ADD:
- Code: Select all
<a onclick="addAllGeoZones();" class="button"><span class="button_left button_insert"></span><span class="button_middle">Add All Countries</span><span class="button_right"></span></a>
4. AT THE BOTTOM OF THAT FILE, ADD:
- Code: Select all
<script type="text/javascript">
function addAllGeoZones() {
<?php foreach ($countries as $k => $v) { ?>
html = '<table class="green" id="zone_to_geo_zone_row' + zone_to_geo_zone_row + '">';
html += '<tr>';
html += '<td><?php echo $entry_country; ?><br /><select name="zone_to_geo_zone[' + zone_to_geo_zone_row + '][country_id]" id="country' + zone_to_geo_zone_row + '" onchange="$(\'#zone' + zone_to_geo_zone_row + '\').load(\'index.php?route=localisation/geo_zone/zone&country_id=\' + this.value + \'&zone_id=0\');">';
<?php foreach ($countries as $country) { ?>
html += '<option value="<?php echo $country['country_id']; ?>" <?php echo (($country['country_id']) == $k+1) ? 'selected="selected"' : ''; ?>><?php echo addslashes($country['name']); ?></option>';
<?php } ?>
html += '</select></td>';
html += '<td rowspan="2"><a onclick="$(\'#zone_to_geo_zone_row' + zone_to_geo_zone_row + '\').remove();" class="button"><span class="button_left button_delete"></span><span class="button_middle"><?php echo $button_remove; ?></span><span class="button_right"></span></a></td>';
html += '</tr>';
html += '<tr>';
html += '<td><?php echo $entry_zone; ?><br /><select name="zone_to_geo_zone[' + zone_to_geo_zone_row + '][zone_id]" id="zone' + zone_to_geo_zone_row + '"></select></td>';
html += '</tr>';
html += '</table>';
$('#zone_to_geo_zone').append(html);
$('#zone' + zone_to_geo_zone_row).load('index.php?route=localisation/geo_zone/zone&country_id=' + $('#country' + zone_to_geo_zone_row).attr('value') + '&zone_id=0');
zone_to_geo_zone_row++;
<?php } ?>
}
</script>
Now insert a new GeoZone. Click the "Add All Countries" button... (wait like 5-10secs as it is very system intensive) Then you should see every country added. Remove the ones you don't want.

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18242
- Joined: Mon Jul 21, 2008 7:02 pm

Re: [MOD] GeoZone - Add All Countries Button
This is fantastic. Is there any way you can modify this so I can add all regions from a country?
-

amplifywebdesign - Posts: 87
- Joined: Fri Aug 21, 2009 5:56 pm
- Location: Sheffield & North Wales
Re: [MOD] GeoZone - Add All Countries Button
It's already implied.

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18242
- Joined: Mon Jul 21, 2008 7:02 pm

Re: [MOD] GeoZone - Add All Countries Button
Qphoria wrote:It's already implied.
Where? I need it so I can edit out some counties
-

amplifywebdesign - Posts: 87
- Joined: Fri Aug 21, 2009 5:56 pm
- Location: Sheffield & North Wales
Re: [MOD] GeoZone - Add All Countries Button
Oh you mean you want to add all zones as well? That would probably crash your browser. To load all countries with each zone individually.
This is more designed for the "rest of the world" where people create 1 zone with the few zones they want at a cheap price. and then they create another zone named "Worldwide" and use this button to add all countries and all zones. Then they can simply remove the few countries they don't want.
If you just want to edit out certain zones of a country, it is not likely you need to do that to ALL countries, so you can do that one manually in its own zone
This is more designed for the "rest of the world" where people create 1 zone with the few zones they want at a cheap price. and then they create another zone named "Worldwide" and use this button to add all countries and all zones. Then they can simply remove the few countries they don't want.
If you just want to edit out certain zones of a country, it is not likely you need to do that to ALL countries, so you can do that one manually in its own zone

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18242
- Joined: Mon Jul 21, 2008 7:02 pm

Re: [MOD] GeoZone - Add All Countries Button
Sorry, I must not be explaining myself well - basically I want to add all Zones from the UK, and then be able to manually remove a couple of them.
I tried doing this by changing the select form to a multi -select:

but it doesn't remember the multiple values :-(
I tried doing this by changing the select form to a multi -select:

but it doesn't remember the multiple values :-(
-

amplifywebdesign - Posts: 87
- Joined: Fri Aug 21, 2009 5:56 pm
- Location: Sheffield & North Wales
Re: [MOD] GeoZone - Add All Countries Button
What a fantastic lifesaver this script was! I was about 1/4 way through manually entering all zones - doh!
Much appreciated, Q!
Much appreciated, Q!
- deeve
- Posts: 250
- Joined: Tue Oct 20, 2009 8:31 am
Re: [MOD] GeoZone - Add All Countries Button
amplifywebdesign wrote:Sorry, I must not be explaining myself well - basically I want to add all Zones from the UK, and then be able to manually remove a couple of them.
I tried doing this by changing the select form to a multi -select:
but it doesn't remember the multiple values :-(
--------------------------
just want to follow up on amplifywebdesign's post...
thanks.
-

dramony - Posts: 258
- Joined: Sat Oct 24, 2009 4:34 am
Re: [MOD] GeoZone - Add All Countries Button
dramony wrote:just want to follow up on amplifywebdesign's post...
I doubt I will get a reply. I just did it the long way in the end, took 15 minutes.
-

amplifywebdesign - Posts: 87
- Joined: Fri Aug 21, 2009 5:56 pm
- Location: Sheffield & North Wales
Re: [MOD] GeoZone - Add All Countries Button
Worked like a charm.
Thank you very much for doing this. Much, much easier and full of awesome.
Thank you very much for doing this. Much, much easier and full of awesome.
- steamcrow
- Posts: 30
- Joined: Sat Aug 15, 2009 8:18 pm
Re: [MOD] GeoZone - Add All Countries Button
Doesn't work for me in V 1.4, what do I have to change?
Thanks
Thanks
- fireatwire
- Posts: 70
- Joined: Tue Feb 02, 2010 9:21 pm
Re: [MOD] GeoZone - Add All Countries Button
Hi,
Trying to implement in 1.4, but the code seems to be different. Has anybody done this for 1.4?
Thank you!
Adam
Trying to implement in 1.4, but the code seems to be different. Has anybody done this for 1.4?
Thank you!
Adam
- asg333
- Posts: 30
- Joined: Sun Jan 10, 2010 4:33 pm
Re: [MOD] GeoZone - Add All Countries Button
I've also got 1.4 and really keen to use this.
Thanks
John
Thanks
John
- whatwhat
- Posts: 4
- Joined: Fri Sep 04, 2009 9:45 am
Re: [MOD] GeoZone - Add All Countries Button
I'll see about updating it

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18242
- Joined: Mon Jul 21, 2008 7:02 pm

Re: [MOD] GeoZone - Add All Countries Button
Hi Q,
I have read your post regarding the mod for adding a Geo Zone called "Rest of The World" i.e. add all countries and then remove the ones you don't want to be in this Zone because you have them listed individually.
http://forum.opencart.com/viewtopic.php?f=23&t=7512#p51581
However, I understand that this mod does not work for OC v1.4.0
When will this be available?
This would be of great assistance.
Ulysses NZ
I have read your post regarding the mod for adding a Geo Zone called "Rest of The World" i.e. add all countries and then remove the ones you don't want to be in this Zone because you have them listed individually.
http://forum.opencart.com/viewtopic.php?f=23&t=7512#p51581
However, I understand that this mod does not work for OC v1.4.0
When will this be available?
This would be of great assistance.
Ulysses NZ
- ulyssesnz
- Posts: 6
- Joined: Sat Feb 13, 2010 3:50 am
Re: [MOD] GeoZone - Add All Countries Button
Hi Q
I also think that having this available in the latest version of OC would be very useful indeed!
Just wondering how other people manage this, for example in 1.4.7?
Thanks in advance for your help!
Rachel
I also think that having this available in the latest version of OC would be very useful indeed!
Just wondering how other people manage this, for example in 1.4.7?
Thanks in advance for your help!
Rachel
- dragonfly
- Posts: 21
- Joined: Sat Jan 30, 2010 12:13 pm
- Location: Wiltshire, UK
Re: [MOD] GeoZone - Add All Countries Button
For OC 1.4.8 AT THE BOTTOM OF THAT FILE, ADD:
- Code: Select all
<script type="text/javascript">
function addAllGeoZones() {
<?php foreach ($countries as $k => $v) { ?>
html = '<table class="green" id="zone_to_geo_zone_row' + zone_to_geo_zone_row + '">';
html += '<tr>';
html += '<td><?php echo $entry_country; ?><br /><select name="zone_to_geo_zone[' + zone_to_geo_zone_row + '][country_id]" id="country' + zone_to_geo_zone_row + '" onchange="$(\'#zone' + zone_to_geo_zone_row + '\').load(\'index.php?route=localisation/geo_zone/zone&country_id=\' + this.value + \'&zone_id=0\');">';
<?php foreach ($countries as $country) { ?>
html += '<option value="<?php echo $country['country_id']; ?>" <?php echo (($country['country_id']) == $k+1) ? 'selected="selected"' : ''; ?>><?php echo addslashes($country['name']); ?></option>';
<?php } ?>
html += '</select></td>';
html += '<td rowspan="2">
<a onclick="$(\'#zone_to_geo_zone_row' + zone_to_geo_zone_row + '\').remove();" class="button"><span class="button_left button_delete"></span><span class="button_middle"><?php echo $button_remove; ?></span><span class="button_right"></span></a></td>';
html += '</tr>';
html += '<tr>';
html += '<td><?php echo $entry_zone; ?><br /><select name="zone_to_geo_zone[' + zone_to_geo_zone_row + '][zone_id]" id="zone' + zone_to_geo_zone_row + '"></select></td>';
html += '</tr>';
html += '</table>';
$('#zone_to_geo_zone').append(html);
$('#zone' + zone_to_geo_zone_row).load('index.php?route=localisation/geo_zone/zone&country_id=' + $('#country' + zone_to_geo_zone_row).attr('value') + '&zone_id=0');
zone_to_geo_zone_row++;
<?php } ?>
}
</script>
- mmijangos
- Posts: 1
- Joined: Sat Sep 11, 2010 9:44 am
Re: [MOD] GeoZone - Add All Countries Button
I tried this in 1.4.8 and it crashed Mozilla after endlessly adding countries for two minutes. Any suggestions?
- PaulineNMU
- Posts: 9
- Joined: Fri Dec 04, 2009 8:59 pm
Re: [MOD] GeoZone - Add All Countries Button
yea.. it is very system intensive and weaker PCs or browsers may have an issue with it.

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18242
- Joined: Mon Jul 21, 2008 7:02 pm

Re: [MOD] GeoZone - Add All Countries Button
Yeah.. I understand that.. Unfortunately, I'm running a 3.0 quad-core with 4 gigs of RAM and I tried it on FireFox and IE and it crashed both. I let it sit for a good 5 minutes and I think it just kept endlessly looping or something. That was using the original code. The new code listed at the bottom of the thread just gives a script error and does nothing.
It's not the end of the world, I put them in manually and increased my World Geography knowledge in the process, but I have another cart to put together next week and I'm gonna need to enter them all again.
Either way, I appreciate the contribution
Even if my system doesn't seem to like it.
(FYI, trying to use this with Zone Shipping Plus - would it be super hard to just add an All Other Zones button to that extension?)
It's not the end of the world, I put them in manually and increased my World Geography knowledge in the process, but I have another cart to put together next week and I'm gonna need to enter them all again.
Either way, I appreciate the contribution
Even if my system doesn't seem to like it.(FYI, trying to use this with Zone Shipping Plus - would it be super hard to just add an All Other Zones button to that extension?)
- PaulineNMU
- Posts: 9
- Joined: Fri Dec 04, 2009 8:59 pm
84 posts
• Page 1 of 5 • 1, 2, 3, 4, 5
Who is online
Users browsing this forum: No registered users and 5 guests













