Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

faster way to delete every country execpt for us?


GRut98034

Recommended Posts

is there a faster way than going to to admin and deleting the countries one by one?

Don't delete countries - it could cause problems with future contributions you might want to install. Instead, install 'Active Countries', which will allow you to only select the united states, so that only ppl from the u.s. can sign up, etc etc.

 

~bobsi18~

Link to comment
Share on other sites

Don't delete countries - it could cause problems with future contributions you might want to install. Instead, install 'Active Countries', which will allow you to only select the united states, so that only ppl from the u.s. can sign up, etc etc.

 

~bobsi18~

thanks, i had already deleted some :( . do u know which files the countries r in?

Link to comment
Share on other sites

thanks, i had already deleted some :( . do u know which files the countries r in?

They're all in the database - if you have a backup, you can just run that, and you should be fine.

Link to comment
Share on other sites

They're all in the database - if you have a backup, you can just run that, and you should be fine.

 

 

Barbara, that's interesting ... please share where deleting excess countries can do harm, I'm always deleting most.

 

 

Fastest way to keep only those countries you need:

- in phpmyadmin, empty table countries

- in the install folder of the oscommerce package files, open oscommerce.sql

- copy countries table insert rows to new file

- in that new file, delete all rows of countries you do not need (in this case only keep one row, USA)

- run statement in phpmyadmin, the rows needed will be inserted

 

I have never before experienced any problems with this method, and it takes 5 minutes - max.

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

Barbara, that's interesting ... please share where deleting excess countries can do harm, I'm always deleting most.

Hi there Monika,

I was just re-iterating what people have told me on the forums - I recently went through the process of trying to figure out what countries I needed and asked advice. I was told that some contributions rely on a countries ID number and that it was safer not to delete the counties, but rather to 'hide' them. I guess it really depends if you are likely to use these extra contribs (can't remember the ezamples given, sorry :))

 

cheers

 

~bobsi18~

Link to comment
Share on other sites

Hi there Monika,

I was just re-iterating what people have told me on the forums - I recently went through the process of trying to figure out what countries I needed and asked advice. I was told that some contributions rely on a countries ID number and that it was safer not to delete the counties, but rather to 'hide' them. I guess it really depends if you are likely to use these extra contribs (can't remember the ezamples given, sorry :))

 

cheers

 

~bobsi18~

 

lol Barbara! It would obviously be a huge mistake to empty the countries table and then to reinsert new countries ... as the countries_id is matched in several other tables (like zones). My method though will keep all references. Perfectly safe in all cases.

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

Don't delete countries - it could cause problems with future contributions you might want to install. Instead, install 'Active Countries', which will allow you to only select the united states, so that only ppl from the u.s. can sign up, etc etc.

 

~bobsi18~

 

the active countries wont work for me tried a few time keeps screwing up site, when i go to site just list somethign error on line

Link to comment
Share on other sites

Monika has a good (and fast) method to rid yourself of all unwanted countries...

 

Another way is to do this (put it in the sql window in phpmyadmin)

 

delete from countries where countries_name <> 'United States';

 

That will get rid of all the countries except the US

 

Active Countries is neat, but I had an abbreviated version that seems to work...if you just want to deactivate some of them. In my case, I will eventually add other countries to ship to...but for now I wanted to narrow the list down to 10 or so.

 

I added a countries_status column to the countries table in the database, for 'status' (0 or 1, for inactive/active).

 

Then I changed the tep_get_countries function so it would retrieve just active countries for the dropdown. I still see all of the others in admin, though.

 

function tep_get_countries($countries_id = '', $with_iso_codes = false) {
$countries_array = array();
if (tep_not_null($countries_id)) {
  if ($with_iso_codes == true) {
	$countries = tep_db_query("select countries_name, countries_iso_code_2, countries_iso_code_3 from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$countries_id . "' order by countries_name");
	$countries_values = tep_db_fetch_array($countries);
	$countries_array = array('countries_name' => $countries_values['countries_name'],
							 'countries_iso_code_2' => $countries_values['countries_iso_code_2'],
							 'countries_iso_code_3' => $countries_values['countries_iso_code_3']);
  } else {
	$countries = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$countries_id . "'");
	$countries_values = tep_db_fetch_array($countries);
	$countries_array = array('countries_name' => $countries_values['countries_name']);
  }
} else {
  $countries = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " where countries_status = '1' order by countries_name");
  while ($countries_values = tep_db_fetch_array($countries)) {
	$countries_array[] = array('countries_id' => $countries_values['countries_id'],
							   'countries_name' => $countries_values['countries_name']);
  }
}

return $countries_array;
 }

 

Then you can use the query that it's in the Active countries readme to deactivate all of the countries...then just go back and activate the ones you need for now.

 

update countries set countries_status = 0

 

Now when I need to activate some more, I can just use phpmyadmin...I don't have red and green buttons to push but it works just as well, with only 3 steps. ;)

 

the active countries wont work for me tried a few time keeps screwing up site, when i go to site just list somethign error on line
Link to comment
Share on other sites

let me add on to this method as I used it last spring for a friend in Ireland. What she needed was a reduced list of countries where she accepted payment from (long list but excluding all countries we know for CC fraud etc etc), so I used my quick method for that part.

 

Then in step2, I added a column, because while she wanted to accept payment from many countries, she would only ship to the EU. That means that when adding a shipping address during checkout she only wanted those allowed countries to show. Well my new column is called ship_to (geez why? lol) and I used the phpmyadmin method with setting the EU countries 1 (default when created was 0).

 

I added a second function, copying the tep_get_countries function, and had the where clause calling only the ship_to = 1.

 

In checkout_new_address, I use that function.

 

there may be someone needing this hack!

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

the active countries wont work for me tried a few time keeps screwing up site, when i go to site just list somethign error on line

 

You should not blindly override files but read the manual instructions. The contribution works and I prefer it over deleting countries because later I may want to expand the store's operations to different continents. And several modules use hard-coded identifiers for countries. So that alone can cause problems if you delete countries from the database because of the auto-increment field.

 

Now I can even have active zones to control the customer, shipping, payment address details and generate tax zones worldwide instantly.

Link to comment
Share on other sites

....so if someone has already deleted all the countries and doesn't have a backup of them, is there a way to get them back ?

:-"

that contribution includes an sql file modified from the world-zones contrib such that the countries/zones are arranged to match the default countries/zones identifiers. So you could restore it from there, or you could extract the countries/zones related tables from the default osc. As long as you only deleted countries/zones you should be ok restoring like that.

Link to comment
Share on other sites

....so if someone has already deleted all the countries and doesn't have a backup of them, is there a way to get them back ?

:-"

if you store a copy of the oscommerce.sql file of your install folder, there is no need to panick here. You can add back the countries you need anytime from it, and it will never cause problems with IDs, as it will not use different autoinsert numbers

 

Mark, sorry but I really disagree here.

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

Mark, sorry but I really disagree here.

 

 

No problem but if you do this:

Fastest way to keep only those countries you need:

- in phpmyadmin, empty table countries

- in the install folder of the oscommerce package files, open oscommerce.sql

- copy countries table insert rows to new file

- in that new file, delete all rows of countries you do not need (in this case only keep one row, USA)

- run statement in phpmyadmin, the rows needed will be inserted

 

you going to have problems with the other tables that are now have no relationship to countries like zones_to_geo_zones, address_book but they do have countries ids stored. Plus any other custom tables or configuration switches that have the countries identifiers. I wouldn't risk doing this on a live store.

Link to comment
Share on other sites

No problem but if you do this:

you going to have problems with the other tables that are now have no relationship to countries like zones_to_geo_zones, address_book but they do have countries ids stored. Plus any other custom tables or configuration switches that have the countries identifiers. I wouldn't risk doing this on a live store.

 

Disclaimer

 

the method I suggested is for a new store, during basic setup, not live yet, no customers, no orders, no zones created using the countries that you do not need ... which I thought was exactly your situation.

Later on, anytime, more countries could be added from the ORIGINAL oscommerce.sql file while keeping the store live - noone would get hurt.

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

yes for new stores should be ok. My only concern is some modules or scripts that hard-code the countries identifiers and if you ever add new countries or zones to the store together with those scripts that include hard-coded identifiers may cause trouble. Because you have the insert country and insert zones switches ready on the osc admin end now. So someone would think that just adding a country from the osc admin would be ok but in reality they should use the default osc sql as you said.

 

One other reason to have this type of control over zones and countries is to create easily any combination of tax zone entries. There are several questions how to create international zones for instance and with the default osc you have to create each entry separately. While with this module you could for example expand all zones of a country with a single click. Or you could select a number of states to insert them right away to a tax zone.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...