Page 4 of 5

Re: [MOD] GeoZone - Add All Countries Button

Posted: Sat Nov 12, 2011 5:13 pm
by sucotronic
jp1976 wrote:mmm... i m not very sure how to hardcode this...
some direction?
Opencart follows a MVC model, so the proper way will be to add a new function in the properly controller file, add a method in the controller and add a button in some template. Sorry not to be more helpful, but I'm just starting to develop in opencart :P

Re: [MOD] GeoZone - Add All Countries Button

Posted: Mon Jan 09, 2012 9:35 pm
by grethat
Exellent work, thank you for your time.

Re: [MOD] GeoZone - Add All Countries Button

Posted: Thu Feb 16, 2012 8:48 am
by thisisworldwide
does anyone have this fix for v1.4.9.6 ? Either the coding fix or the sql fix i couldnt get either to work

Re: [MOD] GeoZone - Add All Countries Button

Posted: Fri Mar 23, 2012 12:57 pm
by komirad
Wow I created the function on the controller->geo_zone.php but after running it the edit page is slow as hell. O0

For a one-time quick use, you may use this function to temporarily replace the "AddGeoZone" function by removing the "AddGeoZone" function and renaming the function below to "AddGeoZone" .

Add a Geo Zone as you normally would, by typing the name/decription except you don't have to add any zones below.

Once you're done, click on edit and all the countries should be in the zone. Page is going to be huge.

Restore the geo_zone.php to the original code once you're done.

Code: Select all

public function addAllCountriesToThisGeoZone($data) {
		$this->db->query("INSERT INTO " . DB_PREFIX . "geo_zone SET name = '" . $this->db->escape($data['name']) . "', description = '" . $this->db->escape($data['description']) . "', date_added = NOW()");

		$geo_zone_id = $this->db->getLastId();
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "country");
		
		foreach($query->rows as $value){
			$this->db->query("INSERT INTO " . DB_PREFIX . "zone_to_geo_zone SET country_id = '"  . (int)$value['country_id'] . "', zone_id = '0', geo_zone_id = '"  .(int)$geo_zone_id . "', date_added = NOW()");
		}
		
		$this->cache->delete('geo_zone');
	}

Re: [MOD] GeoZone - Add All Countries Button

Posted: Thu May 03, 2012 5:15 pm
by iPhone-Unlock.be
Could you explain this better please? I don't understand the instructions above...

Re: [MOD] GeoZone - Add All Countries Button

Posted: Tue Jun 19, 2012 7:21 am
by aaronrrc
Thank you very Much!! :joker:

Re: [MOD] GeoZone - Add All Countries Button

Posted: Fri Jul 27, 2012 4:19 am
by portugalonlineshop
ambrosite wrote:I am really surprised that people are trying to do this with JavaScript? That's crazy. You can set up an "All Countries" Geo Zone in a half second by running a SQL query directly against the database.

First of all, setup the Geo Zone in the admin as you normally would, but don't add any countries or zones to it. Next, you need to know the geo_zone_id of the Geo Zone you just created. You can find it at the end of the URL when you edit the Geo Zone:

http: //www.mystore/admin/index.php?route=local ... _zone_id=4

Now, run the following SQL query using a tool like phpMyAdmin. Make sure you edit the query with the table prefix you selected during the OpenCart installation ('oc_' for my database). You need to enter the correct geo_zone_id in the third field on the second line (it was '4' in my case):

Code: Select all

INSERT INTO oc_zone_to_geo_zone (country_id, zone_id, geo_zone_id, date_added, date_modified)
SELECT oc_country.country_id, 0, 4, NOW(), NOW()
FROM oc_country
WHERE oc_country.name NOT IN ('United States');
That's it! The query will complete in less than two seconds, and it will add all countries and all zones except the United States to your Geo Zone. Note that you can easily edit the query to exclude more than one country. For example, if you wanted to create a Geo Zone for all countries except the US and Canada, you would do this:

Code: Select all

INSERT INTO oc_zone_to_geo_zone (country_id, zone_id, geo_zone_id, date_added, date_modified)
SELECT oc_country.country_id, 0, 4, NOW(), NOW()
FROM oc_country
WHERE oc_country.name NOT IN ('United States','Canada');
Hi guys!

Would it be possible to instead of removing some specific names, one could remove all countries that were present in other geo zone?

Example:
Make a Europe Geo Zone and a Worldwide Geo Zone. Then be able to remove all countries from the Europe zone in the worldwide, or vice-versa..

I've tried messing with mysql, but it's really not my field.. Though of something like this:

Code: Select all

INSERT INTO oc_zone_to_geo_zone (country_id, zone_id, geo_zone_id, date_added, date_modified)
SELECT oc_country.country_id, 0, 4, NOW(), NOW()
FROM oc_country
WHERE oc_zone_to_geo_zone.zone_id NOT IN ('[i]#id for the other geo zone[/i]');
But it does not work...

Re: [MOD] GeoZone - Add All Countries Button

Posted: Sun Sep 09, 2012 11:28 pm
by HankMcSpank
Having set up all my geo zones on one website, I've just created another new website ...to save going through the whole process again, can I just copy some files off my 1st website & then ftp these iover to my 2nd (new) website to see the same geo zones there?

Many thanks,
Hank.

Re: [MOD] GeoZone - Add All Countries Button

Posted: Tue Sep 25, 2012 12:12 am
by tdaubs
Hank, that information is not stored in files but rather the database.

Re: [MOD] GeoZone - Add All Countries Button

Posted: Wed Sep 26, 2012 12:09 am
by HankMcSpank
tdaubs wrote:Hank, that information is not stored in files but rather the database.
Thanks for the info ...in the absence of a reply I just bit the bullet & did it long hand on my new website :-)

Re: [MOD] GeoZone - Add All Countries Button

Posted: Wed Oct 24, 2012 11:35 am
by Simon@j4kofeastpa
Am I able to set up different tax info per state in the USA? For example 6% in pa and 0% in DE?

Thanks

Re: [MOD] GeoZone - Add All Countries Button

Posted: Sat Dec 15, 2012 12:52 am
by Pysiek
Hello
I do have vqmod installed on my web but what I need to do with the vqmode file? Do I need to insert it somewhere?

Re: [MOD] GeoZone - Add All Countries Button

Posted: Sun Dec 16, 2012 12:49 am
by dirtboy
anyone know how to get this to work in 1.5.4.1?

Re: [MOD] GeoZone - Add All Countries Button

Posted: Sat May 25, 2013 1:58 am
by VaporJedi
This doesn't work in 1.5.5.1 .

Any ideas what to do? I installed the vqmod extension.. but it doesnt make the button for all zones/all countries appear.

Re: [MOD] GeoZone - Add All Countries Button

Posted: Sat May 25, 2013 10:08 pm
by OSWorX
VaporJedi wrote:This doesn't work in 1.5.5.1 .

Any ideas what to do? I installed the vqmod extension.. but it doesnt make the button for all zones/all countries appear.
Maybe you want to give this mod (VQMod) a try:
Button Alle Länder DE
Button All Countries EN
Should work also on slower machines.

Re: [MOD] GeoZone - Add All Countries Button

Posted: Tue Jun 18, 2013 11:35 am
by santura
How can I make this mod with vqmod?

Re: [MOD] GeoZone - Add All Countries Button

Posted: Tue Jun 18, 2013 3:45 pm
by OSWorX
santura wrote:How can I make this mod with vqmod?
Do not understand your question.
This IS a VQMod.

Re: [MOD] GeoZone - Add All Countries Button

Posted: Tue Jun 18, 2013 4:18 pm
by santura
Sorry OSWorX I missed your post - thanks

Re: [MOD] GeoZone - Add All Countries Button

Posted: Wed Aug 28, 2013 8:00 pm
by ews.tom
As a long time lurker and OpenCart developer, I finally registered on the forums specifically to say THANKYOU for this VQMod - very helpful

Re: [MOD] GeoZone - Add All Countries Button

Posted: Sun Oct 06, 2013 2:03 am
by emilpk
Here is a simple piece of JavaScript I wrote that did the trick nicely. No need to mess around with updating server side code.

In the chrome console window (or in Firefox's firebug console window), simply run this line of JavaScript.
for(i=1;i<=239;i++){ addGeoZone(); $("#country" + (i-1)).val(i); }

Give it a moment to generate all 239 country picklists with each having the next country in the list auto-selected.

Once you can see the full list of countries have been generated, simply 'Remove' the countries you don't want.

Finally click the 'Save' button and bob's your uncle!