Jump to content
stevel

Country-State Selector

Recommended Posts

You certainly could use this contribution for that purpose. Look back through this thread, it's been discussed before.

 

As for your error, I would guess that you added some other contribution that allows you to selectively enable or disable countries and did not add the required field to the countries table. That is not related to Country-State Selector.

Share this post


Link to post
Share on other sites

Hi Eveyone!!

 

I have had a look at this contribution and it is close to what I want to do, I am wanting something to go up one more level though!!

 

Would it be possible to change it so it gives the user a list of suburbs once they have added there postcode??

 

We use a shipping system that validates the suburb with the postcode and we import batches of deliveries directly into it and we often get import errors when they do not match.

 

If I can added the data into the zones table would it be possible to get it to select the correct suburb and state or would there be to many duplicates for each state as at the moment there is a unique record for each state, if I added the postcodes there would be hundreds of entries for each state..

 

 

Cheers!!

Share this post


Link to post
Share on other sites

Is there more than one suburb per postcode? Is the suburb used for anything other than addressing? (For example, determining tax or shipping rates?) It may be that adding zones is not the way to go. Rather, you could either ask the customer for just the postcode and do a lookup on suburb, or if there is more than one, present the customer with a list similar to the way the standard osC does it if the state is ambiguous.

Share this post


Link to post
Share on other sites

Hi Steve,

 

Thanks for the reply!!

 

There certainly could be more than one suburb for a postcode, it would not be used to calculate tax

but I might use it for shipping rates if it will work in with the shipping module I am running..

 

Basically I want them to first enter their postcode and then get presented with a list of suburbs that match

that postcode that they can select from.

Share this post


Link to post
Share on other sites

Ok, this is how I would handle it. I would have the postcode field have an "onblur" JavaScript action with a call to refresh_form, just the way the contrib calls refresh_form for a change in the Country field. Next, in the zones_query used for displaying the states (zones), I would add a condition to match the postcode, if it is present.

Share this post


Link to post
Share on other sites

I haven't the faintest idea. I have never looked at any of the repackaged versions of osC. The more your files diverge from the standard 2.2-MS2 distribution, the more work you will have to put in to adding the contribution - that applies for any modified versions of 2.2-MS2.

 

The basic concept of Country-State Selector is not difficult, but it does require understanding the form processing logic of each page and adding the relevant refresh code.

Share this post


Link to post
Share on other sites

There is little or no difference with CRE Loaded. I have it and have this installed. I don't remmeber any major issues.

 

Craig

Share this post


Link to post
Share on other sites
Grate contribution, thank you!

 

Just one thing, i ship only 3 countries. how can i set it up?

 

i ship only to my country, and i simply removed all other countries from database :)

Share this post


Link to post
Share on other sites
i ship only to my country, and i simply removed all other countries from database

 

but my customers from all over the world, we do flower deliveries.

Share this post


Link to post
Share on other sites

One way I suppose you could do this is customize the code used in checkout_shipping_address to limit the countries. Another way is to use zone shipping and include only your countries in the zone. That way, a customer won't be able to complete a purchase if the shipping address is not supported. That may confuse customers who entered the address seemingly ok, though.

Share this post


Link to post
Share on other sites

Hi Steve,

 

Thanks for the reply!!

 

I will try to customize the code used in checkout_shipping_address.

And i got got error with refresh on:

 

Line: 409

Char:1

Error:Object expected

Code: 0

URL: http//flowers-armenia.com/create_account.php

 

Any ideas?

Share this post


Link to post
Share on other sites

As I don't know what you changed, it's hard to say. This error indicates that there is a reference to an object (probably form) in the call to refresh which doesn't exist on that page. I'm sorry to say that I won't be able to help you debug this anytime soon.

Share this post


Link to post
Share on other sites

Hey guys,

 

With the latest version, I am having trouble with the admin page noto refreshing. Is this right? E.g If I am on Australia and it shows the australian zone drop down in the admin and I changed the country to US or any other it doesnt re-fresh untill I click update at which point it re-freshes with the new list and then I cna choose from the new state list.

 

is this right? Can someone help me get this to refresh

 

thanks

kris


Don't die with the music in you!!!

 

Failure is just another boundary to sucess!!! But that doesn't mean your getting somewhere...

Share this post


Link to post
Share on other sites

Just wanted to drop you a note and say thank you for this contrib. It rocks and works very well.

 

Thanks again for all the hard work. I really appreciate it.


Just another Squirrel trying to get a nut :D

Share this post


Link to post
Share on other sites

Great Contrib. except I had one problem. It was this error

 

 

United States Postal Service United States Postal Service

-2147219080 - Missing value for Country.

 

 

Good thing i did a complete backup of all my files and was able to uninstall this contrib.

 

I was using usps_shippinglabel_1.7c contrib.

 

 

Just letting you know, the files in the two contribs dont clash, meaning none of the files in either contrib are the same.

 

 

Hoping you would know how to fix this, heh I'm clueless.

 

Thanks,

 

 

Roger

Share this post


Link to post
Share on other sites
Great Contrib. except I had one problem. It was this error

 

 

United States Postal Service United States Postal Service

-2147219080 - Missing value for Country.

Good thing i did a complete backup of all my files and was able to uninstall this contrib.

 

I was using usps_shippinglabel_1.7c contrib.

Just letting you know, the files in the two contribs dont clash, meaning none of the files in either contrib are the same.

Hoping you would know how to fix this, heh I'm clueless.

 

Thanks,

Roger

 

 

I uninstalled your contrib and deleted my account then i reinstalled the contrib and it suddenly works!!!

After I installed the contrib I then changed my country.

 

I think it had something to do with which country was selected already in my account and how it was selecting the country in a different way?

 

Not sure but it works now, hehehe

Share this post


Link to post
Share on other sites

i have v1.2.1 installed

 

i downloaded new version to make sure I had the osc update done correctly in the new files. Noticed that catalog/admin/includes/functions/html_output.php has the following at the end:

// +Country-State Selector
// Adapted from functions in catalog/includes/general.php and html_output.php for Country-State Selector
// Returns an array with countries
// TABLES: countries
 function css_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 . " 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;
 }

////
// Creates a pull-down list of countries
 function css_get_country_list($name, $selected = '', $parameters = '') {
$countries_array = array();

$countries = css_get_countries();

for ($i=0, $n=sizeof($countries); $i<$n; $i++) {
  $countries_array[] = array('id' => $countries[$i]['countries_id'], 'text' => $countries[$i]['countries_name']);
}

return tep_draw_pull_down_menu($name, $countries_array, $selected, $parameters);
 }
// -Country-State Selector
?>

 

Mine doesnt have this.....should it? Did something totally change in newer versions?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×