Post by nightcat » Fri Apr 20, 2012 6:14 pm

I created a "Surface Mail" option under "Geo Zones", unfortunately I have to manually add in every single "Country" into it, very time consuming!

it's there any better way to do it, instead of apply it one by one?

User avatar
New member

Posts

Joined
Mon Aug 15, 2011 1:41 pm

Post by nightcat » Sat Apr 21, 2012 12:43 am

any one can help?

User avatar
New member

Posts

Joined
Mon Aug 15, 2011 1:41 pm

Post by dirtboy » Sat Apr 21, 2012 4:13 am

here is a module to add all geozones. not sure if it will help

http://www.opencart.com/index.php?route ... order=DESC

“Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.”
- Henry Ford


User avatar
Active Member

Posts

Joined
Wed Mar 07, 2012 3:04 pm

Post by nightcat » Sat Apr 21, 2012 1:10 pm

Thank you so much! dirtboy
my first time using "vqmod". It works!
Problem solved!

User avatar
New member

Posts

Joined
Mon Aug 15, 2011 1:41 pm

Post by dirtboy » Sat Apr 21, 2012 1:14 pm

nice, glad it worked for ya

“Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.”
- Henry Ford


User avatar
Active Member

Posts

Joined
Wed Mar 07, 2012 3:04 pm

Post by websitesbymark » Fri Jun 29, 2012 1:25 am

I have found another solution which does not require any modules. Basically what you are going to do is insert all the rows via sql.

To do I added the first country into geo zones.
Then I went into phpmyadmin and did a copy on the last entry of the oc_zone_to_geo_zone table. Instead of doing a copy I displayed the sql and copied the insert statement into excel.
Next I applied a left to the field to seperate out the string up until the country ID (=LEFT(Sheet2!A229,163))
Next I applied a right (=RIGHT(Sheet2!A229,60))

So with the above I have the mysql statement minus the country id

I created a column with numbers from 2 to 239 (to cover the rest of the countries)

I then did a (=CONCATENATE(B229,C229,D229)) to re-combine the mysql

I then pulled down the columns to auto-populate.

This give 238 lines of mysql. Simply copy the column and paste as a mysql query and all is done.

If anyone wants a sample xls please contact me.... (I'm not sure if this board lets me post my email address)


Posts

Joined
Fri Jun 29, 2012 1:15 am

Post by imgoinglive » Sat Nov 09, 2013 1:15 am

Here is a php script I wrote that creates a geo zone for all countries except USA. just copy it into a text editor, add your db info, save the file with anynameyouwant.php load it to your server and run it. simple.

<?php
session_start();
#### you can find this information in your config file
$dbconfig ['host'] = ""; //your database host name goes here
$dbconfig ['user'] = ""; //your database user name goes here
$dbconfig ['pwd'] = ""; //your database password goes here
$dbconfig ['db'] = ""; //your database name goes here
$dbprefix ['prefix'] = ""; //your database prefix goes here

$link = mysql_connect ($dbconfig ['host'], $dbconfig ['user'], $dbconfig ['pwd'])or die ("could not connect");
mysql_select_db ($dbconfig ['db'], $link) or die ("could not select database");

####Sets up a new geo_zone called international####
$table1 = $dbprefix."geo_zone";
$name = "International";
$description = "International";
$now = date("Y-m-d H:i:s");

mysql_query("INSERT INTO '$table1' (name, description, date_modified, date_added ) VALUES ('$name', '$description', '$now', '$now')")or die(mysql_error());

$geo_zone_id = mysql_insert_id(); //gets the id of the geo zone just created

$table2 = $dbprefix."zone_to_geo_zone";
for ($i=1;$i<249;$i++)
{
$now = date("Y-m-d H:i:s");
$country_id = $i;
$zone_id = "0";

if ($country_id == "223"){ //this removes USA
}else{
mysql_query("INSERT INTO '$table2' (country_id, zone_id, geo_zone_id, date_added ) VALUES ('$country_id', '$zone_id', '$geo_zone_id', '$now')")or die(mysql_error());
echo "country_id=".$country_id." and time=".$now."<br>";
}

}
echo "Done!";
?>

User avatar
Newbie

Posts

Joined
Fri Nov 08, 2013 3:44 am
Location - USA

Post by adamhalo » Sat Aug 22, 2015 4:31 pm

Hi there.
I had a similar requirement. I have a Geo Zone for Australia, and wanted one for "rest of the world".

So I created a new Geo Zone called "Elsewhere" and then ran the following the mysql script in phpMyAdmin.

This script basically assigns all countries other than Australia to the "Elsewhere" geo zone. By specifying a zero for zone_ids, I wasn't specifying states, counties, areas with a country.

insert into oc_zone_to_geo_zone (country_id, zone_id, geo_zone_id, date_added, date_modified)
select c.country_id, 0, g.geo_zone_id, now(), now()
from oc_geo_zone g, oc_country c
where upper(g.name) = 'ELSEWHERE'
and upper(c.name) <> 'AUSTRALIA';

Newbie

Posts

Joined
Mon Jul 27, 2015 7:16 pm

Post by PatrickG » Tue Apr 09, 2019 7:55 pm

I was looking for the same thing and I just tried this on Opencart 3.0.3.1 and it worked fine, just had to amend the table name to suit my database. Thanks!

New member

Posts

Joined
Wed Mar 18, 2015 10:32 pm

Post by jude.bright » Thu Oct 17, 2019 2:21 pm

Does this works for 2.3.0.2 kindly let me know.

Newbie

Posts

Joined
Wed Jun 19, 2019 12:59 pm

Post by uksitebuilder » Thu Oct 17, 2019 5:37 pm

Here's a script that will insert all but one country into a geozone

First, create a geozone with no countries in it in your admin panel.

Next, upload the attached to the store root and run it in a browser. e.g. yourdomain.com/xxx.php

ImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by pakchilweb » Fri Nov 06, 2020 5:50 am

uksitebuilder wrote:
Thu Oct 17, 2019 5:37 pm
Here's a script that will insert all but one country into a geozone

First, create a geozone with no countries in it in your admin panel.

Next, upload the attached to the store root and run it in a browser. e.g. yourdomain.com/xxx.php
great solution and really I appreciate you for your post....much helpful and easy

Newbie

Posts

Joined
Sun Jul 15, 2018 7:54 am
Who is online

Users browsing this forum: No registered users and 37 guests