Post by Qphoria » Sun Nov 01, 2009 2:28 am

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.

OpenCart 2.0.x Mod Update Info

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator
Online

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by amplifywebdesign » Sun Nov 01, 2009 3:07 am

This is fantastic. Is there any way you can modify this so I can add all regions from a country?

User avatar

Posts

Joined
Sat Aug 22, 2009 1:56 am
Location - Sheffield & North Wales

Post by Qphoria » Sun Nov 01, 2009 3:22 am

It's already implied.

OpenCart 2.0.x Mod Update Info

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator
Online

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by amplifywebdesign » Sun Nov 01, 2009 9:40 pm

Qphoria wrote:It's already implied.
Where? I need it so I can edit out some counties

User avatar

Posts

Joined
Sat Aug 22, 2009 1:56 am
Location - Sheffield & North Wales

Post by Qphoria » Mon Nov 02, 2009 12:30 am

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

OpenCart 2.0.x Mod Update Info

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator
Online

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by amplifywebdesign » Mon Nov 02, 2009 10: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

Posts

Joined
Sat Aug 22, 2009 1:56 am
Location - Sheffield & North Wales

Post by deeve » Fri Nov 27, 2009 8:01 am

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

Much appreciated, Q!

Newbie

Posts

Joined
Tue Oct 20, 2009 4:31 pm

Post by dramony » Sat Dec 05, 2009 6:13 pm

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
Newbie

Posts

Joined
Sat Oct 24, 2009 12:34 pm

Post by amplifywebdesign » Sun Dec 06, 2009 12:43 am

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

Posts

Joined
Sat Aug 22, 2009 1:56 am
Location - Sheffield & North Wales

Post by steamcrow » Tue Dec 22, 2009 2:17 am

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


Newbie

Posts

Joined
Sun Aug 16, 2009 4:18 am

Post by fireatwire » Thu Feb 04, 2010 3:06 am

Doesn't work for me in V 1.4, what do I have to change?
Thanks

Newbie

Posts

Joined
Wed Feb 03, 2010 5:21 am

Post by asg333 » Fri Feb 05, 2010 5:15 pm

Hi,

Trying to implement in 1.4, but the code seems to be different. Has anybody done this for 1.4?

Thank you!

Adam

Newbie

Posts

Joined
Mon Jan 11, 2010 12:33 am

Post by whatwhat » Tue Feb 09, 2010 8:52 am

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

Thanks
John

Newbie

Posts

Joined
Fri Sep 04, 2009 5:45 pm

Post by Qphoria » Tue Feb 09, 2010 12:57 pm

I'll see about updating it

OpenCart 2.0.x Mod Update Info

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator
Online

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by ulyssesnz » Mon Mar 15, 2010 8: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 ... 512#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

Newbie

Posts

Joined
Sat Feb 13, 2010 11:50 am

Post by dragonfly » Wed Apr 28, 2010 7:38 am

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

Newbie

Posts

Joined
Sat Jan 30, 2010 8:13 pm
Location - Wiltshire, UK

Post by mmijangos » Sat Sep 11, 2010 5:47 pm

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>

Newbie

Posts

Joined
Sat Sep 11, 2010 5:44 pm

Post by PaulineNMU » Tue Sep 14, 2010 1:27 am

I tried this in 1.4.8 and it crashed Mozilla after endlessly adding countries for two minutes. Any suggestions?

Newbie

Posts

Joined
Sat Dec 05, 2009 4:59 am

Post by Qphoria » Tue Sep 14, 2010 1:54 am

yea.. it is very system intensive and weaker PCs or browsers may have an issue with it.

OpenCart 2.0.x Mod Update Info

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator
Online

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by PaulineNMU » Tue Sep 14, 2010 2:59 am

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?)

Newbie

Posts

Joined
Sat Dec 05, 2009 4:59 am
Who is online

Users browsing this forum: No registered users and 7 guests