Page 3 of 3

Re: How to remove all countries and only allow US

Posted: Tue Jul 03, 2012 11:28 pm
by pablodalma
I tried this for version 1.5.3.1 but the country dropdownlist in the registration form hangs out and it is unable to fill the zone dropdownlist . do I have to do something more for it to work in version 1.5.3.1?

Re: How to remove all countries and only allow US

Posted: Tue Jul 10, 2012 2:02 pm
by greensolef
If you want other countries not displayed on the dropdrown,, just simply go to System>Localisation>Countries.
and you will see list of countries there,. now click Edit on the right side of the Country name you want not to appear and select "DISABLE" from the dropdown status and SAVE..

As simple as that!
Hope it helps.

Re: How to remove all countries and only allow US

Posted: Fri Jul 13, 2012 8:00 pm
by Webidea
MatthewB wrote:I used the delete version last year.

But now i am expanding outside the UK is there a way of installing all countries and all zones within the countries again?
I did the same mistake, did you find a way to fix this?

Re: How to remove all countries and only allow US

Posted: Tue Oct 16, 2012 11:40 pm
by MatthewB
Sorry just noticed the reply for me haha

i think it was this i used

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

Re: How to remove all countries and only allow US

Posted: Thu Oct 18, 2012 4:05 am
by rldev
These queries don't work for me in the latest version. I get country' doesn't exist error


I was wrong. I had to put a prefix on the name. Worked great. Thanks so much.

Re: How to remove all countries and only allow US

Posted: Wed Nov 13, 2013 2:38 am
by copper3315
I'm using version 1.5.5.1. Opencart seems to only show enabled countries in the catalog but shows all countries in the admin section. So I wrote the following vqmod which limits results to status = 1. If anyone sees a flaw in this please let me know. Thanks.

<file name="admin/model/localisation/country.php">
<operation error="skip">
<search position="replace"><![CDATA[
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "country ORDER BY name ASC");
]]></search>
<add><![CDATA[
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "country WHERE status = '1' ORDER BY name ASC");
]]></add>
</operation>
</file>

Re: How to remove all countries and only allow US

Posted: Mon Jan 26, 2015 10:40 pm
by ryan0389
hey guys, I know this is an old post but can anyone let me know how to disable all countries EXCEPT Australia and New Zeland?

Posted: Fri Feb 20, 2015 5:50 am
by Novell
I know this is a late answer, but as support on these forums is mostly none existent, and I've had some bad times as well here is my good turn.

This link will help you: http://www.technobezz.com/open-cart-cou ... t-country/

Hope it will turn the tide

Re: How to remove all countries and only allow US

Posted: Fri Feb 20, 2015 8:35 am
by IP_CAM
ryan0389 wrote:hey guys, I know this is an old post but can anyone let me know how to disable all countries EXCEPT Australia and New Zeland?
First, I removed/unclicked all related 'deletable ' Country / Staate / Zone Fields by Use of the built-in MySql-Buddy in my OPENSHOP - OC v.1.5.6.5_rc based Admin section.

Then, I made a backup/download of the MySql-DB. I opened the DB by use of the Notepad++ Editor and manually deleted all Countries, States, Zones, not longer required, from the DB as well.

Then, I reuploaded the modified MySql-CB by use of the OpenShop/OpenCart 'MySql-Buddy'

And it just worked well.

Mentioned it here as well:
http://forum.opencart.com/viewtopic.php ... 56#p543467

So far, I had not one problem, just having about 4'200 less Lines, never ever used anyway, laying around in the DB...

Good Luck
Ernie
bigmax.ch/shop/

Re: How to remove all countries and only allow US

Posted: Fri Feb 20, 2015 6:31 pm
by dswtpl
Hello,

I suggested to disable country in place of delete. If you delete country so it will not longer use to the site. so my personal opinion to disable country. You will make status 0 of country table which you do not want to require.

Thank You. :)

Re: How to remove all countries and only allow US

Posted: Fri Feb 20, 2015 6:39 pm
by vipuljethva
Hello Everyone,

I am in India, I have only India country and state, can you please guide me i remove other country ?

Thank You.

Re: How to remove all countries and only allow US

Posted: Fri Feb 20, 2015 6:43 pm
by dswtpl
Hello Sir,

Execute following query in your your phpmyadmin

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

Thank You. :)

Re: How to remove all countries and only allow US

Posted: Sat Feb 21, 2015 1:34 am
by IP_CAM
dswtpl wrote:If you delete country so it will not longer use to the site
If one can afford to have just about 0.5 Megabyte of Data, unused ever, beeing 'scanned' in each and every DB-Access Task, one may laeve everything, as it comes. For me, it's like driving around in a Car, steady loaded with a 100 Kilo Box in the Trunk, you may don't 'feel' it, but it add's to the energy Bill, because it's a real 'figure'. 4'000 + Lines!

I really believe, that I'm trying vey hard to kill my Shop, searching for the limits of my Server as well as in the Software. But since I never (yet) run into a single Problem, in regard to the 'Line-reduced' DB, I can't see a good reason to leave never ever used Countries, Staates and Zones in my DB.

My 2 Cents, no offense!
Ernie

try to kill it:
http://bigmax.ch/shop/
I pay you a beer (or Coke) :D

Re: How to remove all countries and only allow US

Posted: Sun Mar 20, 2016 9:04 pm
by erik1432
For me in version 2.1.0.2 the code has to be changed a bit to work:

UPDATE oc_country SET status = 0 WHERE country_id <> 150;
UPDATE oc_zone SET status = 0 WHERE country_id <> 150;)

I am not sure if this is for everyone the same but in my database every line has oc_ in front of it.

Re: How to remove all countries and only allow US

Posted: Mon Mar 21, 2016 8:19 pm
by i2Paq
erik1432 wrote:For me in version 2.1.0.2 the code has to be changed a bit to work:

UPDATE oc_country SET status = 0 WHERE country_id <> 150;
UPDATE oc_zone SET status = 0 WHERE country_id <> 150;)

I am not sure if this is for everyone the same but in my database every line has oc_ in front of it.
Because you installed it with a table_prefix = oc

Re: How to remove all countries and only allow US

Posted: Thu May 26, 2016 1:26 am
by i2Paq
Still works for 2.2 :D

Re: How to remove all countries and only allow US

Posted: Sat Apr 15, 2017 11:06 pm
by testje
I made a little simple script te remove countries
create a file calles test.php and put the following code in there

Code: Select all

<?php
include('config.php');

$connecttodb = mysqli_connect(DB_HOSTNAME,DB_USERNAME,DB_PASSWORD,DB_DATABASE) or die(); $GLOBALS['db'] = $connecttodb;


function q($aSQL)
{
        
        $res = $GLOBALS['db']->query($aSQL) or die('Something went wrong');
        return $res;
		
}

//delete countries
if(isset($_GET['delete'])){
	
	
	$deleteid = round($_GET['delete']);
	
	//delete from zone table
	
	q("delete from ".DB_PREFIX."zone where country_id = '$deleteid' ");
	
	//delete from country table
	q("delete from ".DB_PREFIX."country where country_id = '$deleteid' limit 1 ");
	
	
	
}

//show countries

 

$showcontries = q("select  country_id, name
								 from ".DB_PREFIX."country  
									
									order by name ASC ");
									
    
while ($countrylist = $showcontries->fetch_assoc())
				{
					
					 $country = $countrylist["name"];
					  $country_id = $countrylist["country_id"];
					  
					echo "<a href='test.php?delete=".$country_id."'>delete</a> - $country <br>";				
					 
					
				}
And if you now go to yoursite.com/test.php you have a list with countries wich you can easily delete.

!!! Dont forget to remove this file afterwards,
i am not responsible for mistakes.

Best to backup ur database before

Re: How to remove all countries and only allow US

Posted: Sun Apr 16, 2017 4:48 am
by uksitebuilder
I don’t understand the point of this, when you can delete multiple countries via the admin - System - Localisation - Countries section and admin - System -
Localisation - Zones section

You should also be careful as Geo Zones may have some of the deleted countries in them which may cause problems down the line. Again these can be addressed via admin - System - Localisation - Geo Zones section

p.s. I put your code in [ code ] tags to make it readable

Re: How to remove all countries and only allow US

Posted: Mon Jan 08, 2018 5:20 am
by tuncaksoy
testje wrote:
Sat Apr 15, 2017 11:06 pm
I made a little simple script te remove countries
create a file calles test.php and put the following code in there

Code: Select all

<?php
include('config.php');

$connecttodb = mysqli_connect(DB_HOSTNAME,DB_USERNAME,DB_PASSWORD,DB_DATABASE) or die(); $GLOBALS['db'] = $connecttodb;


function q($aSQL)
{
        
        $res = $GLOBALS['db']->query($aSQL) or die('Something went wrong');
        return $res;
		
}

//delete countries
if(isset($_GET['delete'])){
	
	
	$deleteid = round($_GET['delete']);
	
	//delete from zone table
	
	q("delete from ".DB_PREFIX."zone where country_id = '$deleteid' ");
	
	//delete from country table
	q("delete from ".DB_PREFIX."country where country_id = '$deleteid' limit 1 ");
	
	
	
}

//show countries

 

$showcontries = q("select  country_id, name
								 from ".DB_PREFIX."country  
									
									order by name ASC ");
									
    
while ($countrylist = $showcontries->fetch_assoc())
				{
					
					 $country = $countrylist["name"];
					  $country_id = $countrylist["country_id"];
					  
					echo "<a href='test.php?delete=".$country_id."'>delete</a> - $country <br>";				
					 
					
				}
And if you now go to yoursite.com/test.php you have a list with countries wich you can easily delete.

!!! Dont forget to remove this file afterwards,
i am not responsible for mistakes.

Best to backup ur database before

Great Job mate