Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Country-State Selector


stevel

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.

Link to comment
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!!

Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
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?

Link to comment
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.

Link to comment
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...

Link to comment
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

Link to comment
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

Link to comment
Share on other sites

  • 2 weeks later...

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?

Link to comment
Share on other sites

That's to support being able to use the state dropdown in admin when editing customer info. Version 1.2.1 doesn't have that, and it's optional.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...