Page 1 of 3

How to remove all countries and only allow US

Posted: Mon Nov 23, 2009 11:56 am
by actionmedia
Hello,

I've searched and searched the forum however have been unsuccessful at trying to resolve an issue I'm having.

I just installed opencart and am configuring it. Everything works great, except I want to remove ALL countries and only allow USA. I tried deleting the countries, but kept getting errors stating that they're linked to a zone. I'm not sure what else to try.

Any input would be appreciated.

Thank you.

Re: How to remove all countries and only allow US

Posted: Mon Nov 23, 2009 12:09 pm
by Qphoria
Execute this sql in your phpmyadmin

Code: Select all

delete from country where country_id <> 223;
delete from zone where country_id <> 223;

Re: How to remove all countries and only allow US

Posted: Mon Nov 23, 2009 12:21 pm
by actionmedia
Excellent! Thanks a lot!

Re: How to remove all countries and only allow US

Posted: Wed Jan 20, 2010 3:43 pm
by reedmeier@gmail.com
I am looking at phpmyadmin on my server, but do not know how to execute the prior post which says to "Execute sql in your phpmyadmin" Do I cut and paste it somewhere or run something. Sorry, I'm a newb. ;D

Re: How to remove all countries and only allow US

Posted: Wed Jan 20, 2010 3:55 pm
by dbstr
Login to phpMyAdmin, select your database, click the "SQL"-tab in the main frame and you will get a form where you can enter queries ;-)

Re: How to remove all countries and only allow US

Posted: Sat Jul 03, 2010 8:17 am
by Moggin
Qphoria wrote:Execute this sql in your phpmyadmin

Code: Select all

delete from country where country_id <> 223;
delete from zone where country_id <> 223;
Is this still the best way to remove all but one country (using 1.4.8b)? If it's the UK, which number do I need?
Thanks for any advice...

Re: How to remove all countries and only allow US

Posted: Sun Jul 11, 2010 12:43 am
by Moggin
....well, I'm big on self-help, :) so if this helps anyone else:

For the UK, it's 222 (in 1.4.8b); yes, this does remove all countries and zones except the UK, and since it takes about 5 seconds max, is a lot faster than ploughing through the geo-zones and countries in the backoffice. It's a bit scary though, so backup first.

Re: How to remove all countries and only allow US

Posted: Sun Aug 01, 2010 6:23 pm
by JAY6390
that query on any regular server shouldn't take more than a second to execute, I'm guessing it took longer for the request and the page refresh than it did for the query to execute

Re: How to remove all countries and only allow US

Posted: Sun Aug 01, 2010 8:28 pm
by Moggin
JAY6390 wrote:that query on any regular server shouldn't take more than a second to execute, I'm guessing it took longer for the request and the page refresh than it did for the query to execute
lol yes, you're 100% accurate: it was about 1 sec to execute - but add 4 secs to type the query! :laugh: So easy it was unnerving..

Re: How to remove all countries and only allow US

Posted: Sun Aug 01, 2010 9:47 pm
by i2Paq
I want the all to be Disabled instead of Deleted.

Anyone?

Re: How to remove all countries and only allow US

Posted: Sun Aug 01, 2010 10:49 pm
by JAY6390
Not looked at the tables, but I'm guessing there's a status field, which would be

Code: Select all

UPDATE country SET status = 0 WHERE country_id <> 223;
UPDATE zone SET status = 0 WHERE country_id <> 223;

Re: How to remove all countries and only allow US

Posted: Fri Sep 03, 2010 3:29 am
by poorlittlefish
JAY6390 wrote:Not looked at the tables, but I'm guessing there's a status field, which would be

Code: Select all

UPDATE country SET status = 0 WHERE country_id <> 223;
UPDATE zone SET status = 0 WHERE country_id <> 223;
This works on v1.4.9 - thanks very much.

By the way, remember that if you've got any kind of prefix on your database tables you'll need to change 'country' and 'zone' to whatever your tables are called.

Re: How to remove all countries and only allow US

Posted: Fri Sep 03, 2010 4:36 am
by Moggin
This is about a month late, but THANKS from me too, Jay. That 'disable' query works perfectly, and I prefer it to the 'delete' solution.
So, for any other noobs out there applying this fix for the UK, the above code needs to change to 222, and you're sorted.

I'm not sure why, but you have to go into the admin panel, open and 'save' one of the disabled countries and zones, for the changes to show in the shop.

Re: How to remove all countries and only allow US

Posted: Fri Nov 12, 2010 1:51 am
by i2Paq
Works on 1.4.9.2, Netherlands: 150

Re: How to remove all countries and only allow US

Posted: Fri Nov 12, 2010 10:58 am
by Qphoria
I added status in 1.4.8 so that should work for all versions since then.
I am going to look into more mass-edit/mass-toggle options in 1.5.0 or 1.5.1

Re: How to remove all countries and only allow US

Posted: Sat Mar 19, 2011 10:40 pm
by rocketero
After disabling (Status = 0) all countries and zones, except for the country/zone of store's location, still a customer can add/create an account with an address residing in any country, except that the region/province does show empty.

I thought that after disabling all countries/zones except for the one of business, the account/create or the account/address(insert) wouldn't show those countries already with status = 0.

Re: How to remove all countries and only allow US

Posted: Sat Mar 19, 2011 11:25 pm
by FnF
If your still seeing other countries in the list you might not have executed the SQl query properly. But someone mentioned somewhere, having to click edit on one of the disabled countries and then saving again in order for the deletee countries to stop showing.
I dont know what that would do, and I didnt have to do it, but did you try it?

The other thing, if your using only one country, have you created a Geo Zone for that country?

Re: How to remove all countries and only allow US

Posted: Sun Mar 20, 2011 6:50 am
by rocketero
now is working, but after executing a sql query to delete all countries except for the one I needed.

Before I did what you mentioned, I clicked on a disabled country and saved it again, that didn't do it for me, and after deleting the countries then it worked, and I did already had created a geo-zone for my country.
So all good now. thanks.

Re: How to remove all countries and only allow US

Posted: Sun Mar 20, 2011 9:50 am
by Moggin
FnF wrote:.. click edit on one of the disabled countries and then saving again in order for the deletee countries to stop showing. I dont know what that would do..
No, me neither. ;) But after disabling the countries/zones in the DB they still appeared in the drop down. When I carried out that strange procedure, all was well again. Maybe it's a cache thing.

Re: How to remove all countries and only allow US

Posted: Wed Mar 23, 2011 2:28 am
by Adisan
Moggin is right; if the countries do not show in the dropdown menu

( even after you did run this code:

UPDATE country SET status = 0 WHERE country_id <> 223;
UPDATE zone SET status = 0 WHERE country_id <> 223;)
,
just delete all the files in the system/cache folder except the index.html, that should solve it; in my case did.
And thanks for the help guys, I appreciate it!