Zen Cart Logo
Forums / Basic Configuration / Remove all countries at once except one.

Remove all countries at once except one.

Views: 2,836

Results 1 to 5 of 5
6 Dec 2023, 9:23 PM
#1
stuffdone avatar

stuffdone

Zen Follower

Join Date:
Jul 2007
Posts:
156
Plugin Contributions:
0

Remove all countries at once except one.

How does one remove all countries except one without having to go through hundreds of clicks one by one?

Please don't just say edit SQL without more info about that.

6 Dec 2023, 9:47 PM
#2
balihr avatar

balihr

Totally Zenned

Join Date:
Oct 2008
Location:
Croatia
Posts:
1,784
Plugin Contributions:
21

Re: Remove all countries at once except one.

If you're 100% sure you want to remove them, an SQL command would be enough. You would need to know the ID of the country, but you could go with the name... For example, US is 223, but you could use "United States" as well.
admin->Tools->Install SQL Patches

DELETE FROM countries WHERE countries_id != 223;

or, based on name:

DELETE FROM countries WHERE countries_name NOT LIKE 'United States';

As always, don't just run the query, make sure you read and follow the bold red text on the "Install SQL Patches" page...

6 Dec 2023, 11:36 PM
#3
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,085
Plugin Contributions:
56

Re: Remove all countries at once except one.

... or better yet, for zc156 and later, just 'disable' the countries:

UPDATE countries SET status = 0 WHERE countries_id != 223;

or

UPDATE countries SET status = 0 WHERE countries_name != 'United States';

To disable all countries but the USA.

23 Jan 2024, 9:02 PM
#4
enigmawanderer avatar

enigmawanderer

New Zenner

Join Date:
Jan 2024
Posts:
2
Plugin Contributions:
0

Re: Remove all countries at once except one.

Hi,

I see that there were several suggestions provided for removing all countries except one in the Zen Cart forum. Could you please share which method you chose to implement, and more importantly, could you confirm whether it worked for your specific case?