Community Forums

[MOD] GeoZone - Add All Countries Button

Community created contributions & mods for OpenCart 1.x

[MOD] GeoZone - Add All Countries Button

Postby Qphoria » Sat Oct 31, 2009 6:28 pm

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:
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.
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18242
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] GeoZone - Add All Countries Button

Postby amplifywebdesign » Sat Oct 31, 2009 7:07 pm

This is fantastic. Is there any way you can modify this so I can add all regions from a country?
User avatar
amplifywebdesign
 
Posts: 87
Joined: Fri Aug 21, 2009 5:56 pm
Location: Sheffield & North Wales

Re: [MOD] GeoZone - Add All Countries Button

Postby Qphoria » Sat Oct 31, 2009 7:22 pm

It's already implied.
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18242
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] GeoZone - Add All Countries Button

Postby amplifywebdesign » Sun Nov 01, 2009 1:40 pm

Qphoria wrote:It's already implied.


Where? I need it so I can edit out some counties
User avatar
amplifywebdesign
 
Posts: 87
Joined: Fri Aug 21, 2009 5:56 pm
Location: Sheffield & North Wales

Re: [MOD] GeoZone - Add All Countries Button

Postby Qphoria » Sun Nov 01, 2009 4:30 pm

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
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18242
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] GeoZone - Add All Countries Button

Postby amplifywebdesign » Mon Nov 02, 2009 2:49 pm

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:
Image


but it doesn't remember the multiple values :-(
User avatar
amplifywebdesign
 
Posts: 87
Joined: Fri Aug 21, 2009 5:56 pm
Location: Sheffield & North Wales

Re: [MOD] GeoZone - Add All Countries Button

Postby deeve » Fri Nov 27, 2009 12:01 am

What a fantastic lifesaver this script was! I was about 1/4 way through manually entering all zones - doh!

Much appreciated, Q!
deeve
 
Posts: 250
Joined: Tue Oct 20, 2009 8:31 am

Re: [MOD] GeoZone - Add All Countries Button

Postby dramony » Sat Dec 05, 2009 10:13 am

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:
Image


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


--------------------------

just want to follow up on amplifywebdesign's post...
thanks.
User avatar
dramony
 
Posts: 258
Joined: Sat Oct 24, 2009 4:34 am

Re: [MOD] GeoZone - Add All Countries Button

Postby amplifywebdesign » Sat Dec 05, 2009 4:43 pm

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.
User avatar
amplifywebdesign
 
Posts: 87
Joined: Fri Aug 21, 2009 5:56 pm
Location: Sheffield & North Wales

Re: [MOD] GeoZone - Add All Countries Button

Postby steamcrow » Mon Dec 21, 2009 6:17 pm

Worked like a charm.

Thank you very much for doing this. Much, much easier and full of awesome.
Daniel M. Davis

[url=http://www.steamcrow.com]

http://www.twitter.com/steamcrow
steamcrow
 
Posts: 30
Joined: Sat Aug 15, 2009 8:18 pm

Re: [MOD] GeoZone - Add All Countries Button

Postby fireatwire » Wed Feb 03, 2010 7:06 pm

Doesn't work for me in V 1.4, what do I have to change?
Thanks
fireatwire
 
Posts: 70
Joined: Tue Feb 02, 2010 9:21 pm

Re: [MOD] GeoZone - Add All Countries Button

Postby asg333 » Fri Feb 05, 2010 9:15 am

Hi,

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

Postby whatwhat » Tue Feb 09, 2010 12:52 am

I've also got 1.4 and really keen to use this.

Thanks
John
whatwhat
 
Posts: 4
Joined: Fri Sep 04, 2009 9:45 am

Re: [MOD] GeoZone - Add All Countries Button

Postby Qphoria » Tue Feb 09, 2010 4:57 am

I'll see about updating it
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18242
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] GeoZone - Add All Countries Button

Postby ulyssesnz » Mon Mar 15, 2010 12:51 am

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
ulyssesnz
 
Posts: 6
Joined: Sat Feb 13, 2010 3:50 am

Re: [MOD] GeoZone - Add All Countries Button

Postby dragonfly » Tue Apr 27, 2010 11:38 pm

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
dragonfly
 
Posts: 21
Joined: Sat Jan 30, 2010 12:13 pm
Location: Wiltshire, UK

Re: [MOD] GeoZone - Add All Countries Button

Postby mmijangos » Sat Sep 11, 2010 9:47 am

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

Postby PaulineNMU » Mon Sep 13, 2010 5:27 pm

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

Postby Qphoria » Mon Sep 13, 2010 5:54 pm

yea.. it is very system intensive and weaker PCs or browsers may have an issue with it.
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18242
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] GeoZone - Add All Countries Button

Postby PaulineNMU » Mon Sep 13, 2010 6:59 pm

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?)
PaulineNMU
 
Posts: 9
Joined: Fri Dec 04, 2009 8:59 pm

Next

Return to Free Contributions

Who is online

Users browsing this forum: No registered users and 5 guests

Hosted by Arvixe Web Hosting