Post by jomoweb » Sat May 10, 2008 4:07 am

The following SQL will remove all countries and zones EXCEPT for the United States and its 50 states.  This can be done through phpadmin or similar MySql db administrator.  This update is not for the faint of heart, but I have tested it and found no problems with the back or front end.

1. Backup / Export your database.  I am not responsible if your store crashes and dies because you didn't take this simple precaution.
2. Double check to see if United States "country_ID" is 223.  If not, find and replace with whatever number it is throughout this sql snippet.
3. If you want to do something similar with a different country, find out that countries "country_id" and re-write the zone entries with whatever zones you need.

The statement:

Code: Select all

DROP TABLE IF EXISTS `zone`;
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE TABLE `zone` (
  `zone_id` int(11) NOT NULL auto_increment,
  `country_id` int(11) NOT NULL default '0',
  `code` varchar(32) NOT NULL default '',
  `name` varchar(32) NOT NULL default '',
  PRIMARY KEY  (`zone_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3842 ;

INSERT INTO `zone` VALUES(1, 223, 'AL', 'Alabama');
INSERT INTO `zone` VALUES(2, 223, 'AK', 'Alaska');
INSERT INTO `zone` VALUES(3, 223, 'AZ', 'Arizona');
INSERT INTO `zone` VALUES(4, 223, 'AR', 'Arkansas');
INSERT INTO `zone` VALUES(5, 223, 'CA', 'California');
INSERT INTO `zone` VALUES(6, 223, 'CO', 'Colorado');
INSERT INTO `zone` VALUES(7, 223, 'CT', 'Connecticut');
INSERT INTO `zone` VALUES(8, 223, 'DE', 'Delaware');
INSERT INTO `zone` VALUES(9, 223, 'FL', 'Florida');
INSERT INTO `zone` VALUES(10, 223, 'GA', 'Georgia');
INSERT INTO `zone` VALUES(11, 223, 'HI', 'Hawaii');
INSERT INTO `zone` VALUES(12, 223, 'ID', 'Idaho');
INSERT INTO `zone` VALUES(13, 223, 'IL', 'Illinois');
INSERT INTO `zone` VALUES(14, 223, 'IN', 'Indiana');
INSERT INTO `zone` VALUES(15, 223, 'IA', 'Iowa');
INSERT INTO `zone` VALUES(16, 223, 'KS', 'Kansas');
INSERT INTO `zone` VALUES(17, 223, 'KY', 'Kentucky');
INSERT INTO `zone` VALUES(18, 223, 'LA', 'Louisiana');
INSERT INTO `zone` VALUES(19, 223, 'ME', 'Maine');
INSERT INTO `zone` VALUES(20, 223, 'MD', 'Maryland');
INSERT INTO `zone` VALUES(21, 223, 'MA', 'Massachusetts');
INSERT INTO `zone` VALUES(22, 223, 'MI', 'Michigan');
INSERT INTO `zone` VALUES(23, 223, 'MN', 'Minnesota');
INSERT INTO `zone` VALUES(24, 223, 'MS', 'Mississippi');
INSERT INTO `zone` VALUES(25, 223, 'MO', 'Missouri');
INSERT INTO `zone` VALUES(26, 223, 'MT', 'Montana');
INSERT INTO `zone` VALUES(27, 223, 'NE', 'Nebraska');
INSERT INTO `zone` VALUES(28, 223, 'NV', 'Nevada');
INSERT INTO `zone` VALUES(29, 223, 'NH', 'New Hampshire');
INSERT INTO `zone` VALUES(30, 223, 'NJ', 'New Jersey');
INSERT INTO `zone` VALUES(31, 223, 'NM', 'New Mexico');
INSERT INTO `zone` VALUES(32, 223, 'NY', 'New York');
INSERT INTO `zone` VALUES(33, 223, 'NC', 'North Carolina');
INSERT INTO `zone` VALUES(34, 223, 'ND', 'North Dakota');
INSERT INTO `zone` VALUES(35, 223, 'OH', 'Ohio');
INSERT INTO `zone` VALUES(36, 223, 'OK', 'Oklahoma');
INSERT INTO `zone` VALUES(37, 223, 'OR', 'Oregon');
INSERT INTO `zone` VALUES(38, 223, 'PA', 'Pennsylvania');
INSERT INTO `zone` VALUES(39, 223, 'RI', 'Rhode Island');
INSERT INTO `zone` VALUES(40, 223, 'SC', 'South Carolina');
INSERT INTO `zone` VALUES(41, 223, 'SD', 'South Dakota');
INSERT INTO `zone` VALUES(42, 223, 'TN', 'Tennessee');
INSERT INTO `zone` VALUES(43, 223, 'TX', 'Texas');
INSERT INTO `zone` VALUES(44, 223, 'UT', 'Utah');
INSERT INTO `zone` VALUES(45, 223, 'VT', 'Vermont');
INSERT INTO `zone` VALUES(46, 223, 'VA', 'Virginia');
INSERT INTO `zone` VALUES(47, 223, 'WA', 'Washington');
INSERT INTO `zone` VALUES(48, 223, 'WV', 'West Virginia');
INSERT INTO `zone` VALUES(49, 223, 'WI', 'Wisconsin');
INSERT INTO `zone` VALUES(50, 223, 'WY', 'Wyoming');


DROP TABLE IF EXISTS `country`;
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE TABLE `country` (
  `country_id` int(11) NOT NULL auto_increment,
  `name` varchar(64) collate utf8_unicode_ci NOT NULL default '',
  `iso_code_2` varchar(2) collate utf8_unicode_ci NOT NULL default '',
  `iso_code_3` varchar(3) collate utf8_unicode_ci NOT NULL default '',
  `address_format` text collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`country_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=240 ;


INSERT INTO `country` VALUES(223, 'United States', 'US', 'USA', '');

Newbie

Posts

Joined
Thu Feb 21, 2008 3:11 am

Post by gibpat » Tue Jun 10, 2008 9:18 am

Yeh i think ive done something wrong here, ive edited the script to remove all countries except australia, now when i go to checkout i cannot give a payment method...

Also when i retore the backup it doesnt restore everything as it was, all my states under australia point to another country.

Have i dont something wrong with the sql file?
Any advice would be great.

-Dave
jomoweb wrote:

Code: Select all

DROP TABLE IF EXISTS `zone`;
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE TABLE `zone` (
  `zone_id` int(11) NOT NULL auto_increment,
  `country_id` int(11) NOT NULL default '0',
  `code` varchar(32) NOT NULL default '',
  `name` varchar(32) NOT NULL default '',
  PRIMARY KEY  (`zone_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3842 ;

INSERT INTO `zone` VALUES(1, 13, 'ACT', 'Australian Capitol Territory');
INSERT INTO `zone` VALUES(2, 13, 'NSW', 'New South Wales');
INSERT INTO `zone` VALUES(3, 13, 'NT', 'Northern Territory');
INSERT INTO `zone` VALUES(4, 13, 'QLD', 'Queensland');
INSERT INTO `zone` VALUES(5, 13, 'SA', 'South Australia');
INSERT INTO `zone` VALUES(6, 13, 'TAS', 'Tasmania');
INSERT INTO `zone` VALUES(7, 13, 'VIC', 'Victoria');
INSERT INTO `zone` VALUES(8, 13, 'WA', 'Western Australia');


DROP TABLE IF EXISTS `country`;
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE TABLE `country` (
  `country_id` int(11) NOT NULL auto_increment,
  `name` varchar(64) collate utf8_unicode_ci NOT NULL default '',
  `iso_code_2` varchar(2) collate utf8_unicode_ci NOT NULL default '',
  `iso_code_3` varchar(3) collate utf8_unicode_ci NOT NULL default '',
  `address_format` text collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`country_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=240 ;


INSERT INTO `country` VALUES(13, 'Australia', 'AU', 'AUS', '');

New member

Posts

Joined
Fri Jun 06, 2008 9:09 am

Post by bruce » Tue Jun 10, 2008 9:30 am

Back it up first, but you should have a look at zone_to_geo_zone and truncate it. You can then add the appropriate links via the admin.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by gibpat » Tue Jun 10, 2008 9:39 am

bruce wrote: Back it up first, but you should have a look at zone_to_geo_zone and truncate it. You can then add the appropriate links via the admin.
Sorry bruce, but how do i 'truncate' it?

-d

New member

Posts

Joined
Fri Jun 06, 2008 9:09 am

Post by gibpat » Wed Jun 11, 2008 11:08 am

Ok, I did the following:
# mysql store_db
mysql> SET AUTOCOMMIT=1;
mysql> TRUNCATE TABLE zone_to_geo_zone;
mysql> quit

but my payment section is still missing... any ideas?

New member

Posts

Joined
Fri Jun 06, 2008 9:09 am

Post by bruce » Wed Jun 11, 2008 3:15 pm

Modify your payment definition to include "All Zones". This is a bit of a misnomer because it is really "All Geo Zones".

If you have already done this, then PM david with your details and let him fix it up for you.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by gibpat » Thu Jun 12, 2008 8:41 am

Well i ended up editing out everything from opencart.sql and created a new store using the edited file, everything works fine now.
Thanks for all your assistance guys!

-dave

New member

Posts

Joined
Fri Jun 06, 2008 9:09 am
Who is online

Users browsing this forum: No registered users and 1 guest