Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Country-State Selector


stevel

Recommended Posts

When I first did a combination of C-SS with PWA, the current PWA version was 0.90. In PWA 0.91, I think, the PWA author took my changes and merged them into the PWA contrib, including a combined file for those who use C-SS. I see that there have been random others who have created "1.02" versions, but those seem to be variants of the basic code and I have not looked at them in detail.

Link to comment
Share on other sites

When I first did a combination of C-SS with PWA, the current PWA version was 0.90. In PWA 0.91, I think, the PWA author took my changes and merged them into the PWA contrib, including a combined file for those who use C-SS. I see that there have been random others who have created "1.02" versions, but those seem to be variants of the basic code and I have not looked at them in detail.

 

Thank you.

Sonia,

Link to comment
Share on other sites

Since you're using STS - please reread the troubleshooting tips in the Country-State Selector readme. In particular, note that the template contribs tend to have two separate copies of form_check.js.php and you have to update both of them.

 

 

Hi. I'm getting the same error from the same spot in the code so I assume the error must be in the directions. Were you able to track down the missing or deleted bracket???

 

Many Thanks!

Link to comment
Share on other sites

Hi Stevel

 

Thanx for this contribution .. i had a lot of probelms with people not selecting correct state and then they didn't have tax calculated proper .. with this contribution this is over :thumbsup:

 

but i ran to famouse parse error T CASE in line 203

 

		} else if ($error == true) {
	  $cInfo = new objectInfo($HTTP_POST_VARS);
				$processed = true;
	  // +Country-State Selector
	  } else if ($refresh == 'true') {
		$cInfo = new objectInfo($HTTP_POST_VARS);
	  }
	  // -Country-State Selector
	}

	break;
case 'deleteconfirm':
	$customers_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);

	if (isset($HTTP_POST_VARS['delete_reviews']) && ($HTTP_POST_VARS['delete_reviews'] == 'on')) {
	  $reviews_query = tep_db_query("select reviews_id from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers_id . "'");
	  while ($reviews = tep_db_fetch_array($reviews_query)) {
		tep_db_query("delete from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$reviews['reviews_id'] . "'");

 

case 'deleteconfirm': is line 203

 

since i'm no programmer any help would be appriciated...

 

thanx

 

Hi. I'm getting the same error from the same spot in the code so I assume the error must be in the directions. Were you able to track down the missing or deleted bracket???

 

Many Thanks!

Link to comment
Share on other sites

Hi. I'm getting the same error from the same spot in the code so I assume the error must be in the directions. Were you able to track down the missing or deleted bracket???

 

Many Thanks!

 

I found it!

 

Open the file:

/catalog/admin/customers.php

 

Search for:

 

if (ACCOUNT_DOB == 'true') {

if (checkdate(substr(tep_date_raw($customers_dob), 4, 2), substr(tep_date_raw($customers_dob), 6, 2), substr(tep_date_raw($customers_dob), 0, 4))) {

$entry_date_of_birth_error = false;

} else {

$error = true;

$entry_date_of_birth_error = true;

}

}

 

DELETE the last }

 

So it should now look like:

 

if (ACCOUNT_DOB == 'true') {

if (checkdate(substr(tep_date_raw($customers_dob), 4, 2), substr(tep_date_raw($customers_dob), 6, 2), substr(tep_date_raw($customers_dob), 0, 4))) {

$entry_date_of_birth_error = false;

} else {

$error = true;

$entry_date_of_birth_error = true;

}

 

Save.

Upload.

 

Boo-yah!

 

Many thanks to me for find the error. J/K!

 

Thanks to the Author for the great contrib!

Link to comment
Share on other sites

Cool contribution! I have everything working except the address book. If I log in as a customer, and go to my account and attempt to add an address to my address book--

The country is not prepopulated as it is in the checkout process. Also the page does not refresh when actually choosing a country so there are no states to choose from.

 

I did the script error thing in IE and it says:

Line 118

CH 28

Syntax error.

 

No big deal but when I choose United States from the pull down, then I get this error:

Line 290

1

object expected

 

I copied the source data into textpad and line 290 is this one:

<td class="main"><select name="country" onChange="return refresh_form(addressbook);"><option value="" SELECTED>Please Select</option><option value="1">Afghanistan</option><option value="2">Albania</option><option value="3">Algeria</option><option value="4">American Samoa</option><option value="5">Andorra</option><option value="6">Angola</option><option value="7">Anguilla</option><option value="8">Antarctica</option><option value="9">Antigua and Barbuda</option><option value="10">Argentina</option><option value="11">Armenia</option><option etc 
etc 
etc
Yugoslavia</option><option value="237">Zaire</option><option value="238">Zambia</option><option value="239">Zimbabwe</option></select>?<span class="inputRequirement">* (Page will refresh when changed)</span></td>

Any ideas where I went wrong?

Link to comment
Share on other sites

The script error is a "big deal". This could be interfering with the rest. Fix the script error and the rest may fall into place.

Thanks for the quick answer Steve.

 

I said the first was no big deal because I have several pages that have that same error on them. I have no idea what is causing them and until now, they were pretty unimportant. I did a little research way back when I first noticed them. I guess I need to dig deeper. As I recall, I have several pages that give that same error:

Line 118

Ch 28

Syntax error.

 

Luckily for me the other pages all work fine.

 

Tim

Link to comment
Share on other sites

I did a quick check and found out this.

The 'my account' page is divided into several groups of links.

overview

my account'

my orders

e-mail notifications.

 

All the links under 'my account' give the same syntax error. Same line same character.

Link to comment
Share on other sites

I just installed the latest country-state selector that includes support for PWA. However, I noticed that the provided create_account.php and Order_Info.php files are the same.

 

I have looked through the forums and I don't find that this has been identified (but I may have missed it).

 

Please advise.

Link to comment
Share on other sites

They're not the same. They're not even close to the same. Not even the same size.

 

 

When I unzipped the downloaded files with winzip, both files in the PWA/catalog folder were shown to be 25K and when I opened each one up the top lines indicated the name of the files were create_account.php. Based on the similarities, I thought that perhaps the files had accidentally been duplicated. As I look into the file more, I see that the files are different sizes.

 

Thanks for making the modifications to support PWA.

Link to comment
Share on other sites

  • 2 weeks later...

Hey Steve,

 

Just wanted to take a second to thank you for setting up such an excellent contrib. So many of the contribs on this site are coded poorly and impossible to read. I found your instructions and code to be excellent and this was very easy to install.

 

Its just sad that functionality that I feel should be one of the most basic things to be included in oscommerce from the get go would have to be added via contrib...

 

Cheers :thumbsup:

 

Jay

Link to comment
Share on other sites

Hi,

 

i have this great contrib installed and it works fine. But i have any problem with my template (BTS).

 

When i will change the shipping address in checkout_shipping_address.php and i change the country, then i redirect to checkout_shipping.php.

 

Can someone help me?

 

Sorry for my english!

 

Regards,

Bastian

Link to comment
Share on other sites

  • 2 weeks later...

First - EXCELLENT contribution! This was the first one I installed on my long trek to getting my oscommerce shop up and running.

 

I finally got around to figuring out my tax setup (bear with me, this really does relate to Country-State Selector) Anyway, I'm in Colorado so I have to care about sales tax in my own county OR in all other counties in the state. After reviewing how other people have setup taxes for counties in a state I have now created two tax zones:

 

zone_id zone_country_id zone_code zone_name

13 223 CO Colorado

79 223 CO Colorado (Douglas County)

 

Everything was going along swimmingly until I tried to use the Change Address in either the shipping page or billing page. I kept getting the error "Please select a state from the States pull down menu." After some review, I determined this was happening in checkout_shipping_address.php (approx line 111) and checkout_payment_address.php (approx line 98). The code that selects the zone_id is having fits because of my similar beginning zone_names above (Colorado% will match both zone_names). So, I figure that since this is in a section of code that knows there are zones, and sinze I'm using Country-State Selector I don't really need the matching logic in the SQL that's included. If I recall correctly, this type check was replaced/removed by this contribution in the create_account.php file.

 

I changed

		  $zone_query = tep_db_query("select distinct zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and (zone_name like '" . tep_db_input($state) . "%' or zone_code like '%" . tep_db_input($state) . "%')");

 

to be

		  $zone_query = tep_db_query("select distinct zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and zone_name = '" . tep_db_input($state) . "'");

 

It seems to me that this edit could be safely included in the next release of Country-State Selector?

 

Does anyone see any problems with this change?

Link to comment
Share on other sites

Bastian, it sounds as if you have an error in your checkout_shipping_address.php file in that the form submit action specifies the wrong file.

 

Nathan, you found a bug I discovered myself a short while ago - I was in the process of updating the contrib to fix it. There's a bit more to it than what you have - there's also code at the top of the file that displays that error which needs to be disabled. Let me look at my code tonight and make a suggestion.

Link to comment
Share on other sites

Ok. In checkout_payment_address.php and checkout_shipping_address.php, make these edits:

 

Replace this:

	  if (ACCOUNT_STATE == 'true') {
	$zone_id = 0;
	$check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "'");
	$check = tep_db_fetch_array($check_query);
	$entry_state_has_zones = ($check['total'] > 0);
	if ($entry_state_has_zones == true) {
	  $zone_query = tep_db_query("select distinct zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and (zone_name like '" . tep_db_input($state) . "%' or zone_code like '%" . tep_db_input($state) . "%')");
	  if (tep_db_num_rows($zone_query) == 1) {
		$zone = tep_db_fetch_array($zone_query);
		$zone_id = $zone['zone_id'];
	  } else {
		$error = true;

		$messageStack->add('checkout_address', ENTRY_STATE_ERROR_SELECT);
	  }
	} else {

with this:

	  if (ACCOUNT_STATE == 'true') {
   // +Country-State Selector
	if ($zone_id == 0) {
  // -Country-State Selector

 

In includes/modules/checkout_new_address.php, replace this:

// +Country-State Selector
	$zones_array = array();
	 $zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = " . (int) $country . " order by zone_name");
	while ($zones_values = tep_db_fetch_array($zones_query)) {
	  $zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);
	}
	if (count($zones_array) > 0) {
	  echo tep_draw_pull_down_menu('state', $zones_array);
	} else {
	  echo tep_draw_input_field('state');
	}
// -Country-State Selector

with this:

// +Country-State Selector
	$zones_array = array();
	$zones_query = tep_db_query("select zone_id, zone_name from " . TABLE_ZONES . " where zone_country_id = " . (int)$country . " order by zone_name");
	while ($zones_values = tep_db_fetch_array($zones_query)) {
	  $zones_array[] = array('id' => $zones_values['zone_id'], 'text' => $zones_values['zone_name']);
	}
		  if (count($zones_array) > 0) {
	  echo tep_draw_pull_down_menu('zone_id', $zones_array, $zone_id);
		  } else {
			echo tep_draw_input_field('state');
		  }
// -Country-State Selector

 

Try this and let me know how it works for you.

Link to comment
Share on other sites

Steve:

Is the code change for everyone who has installed your contribution or is the change a special fix for some problem that occurs with a combination of contributions.

Many thanks.

Dennis

Link to comment
Share on other sites

It's for everyone. You would not notice a problem unless:

 

1: A user selected a zone that is a substring of another zone, or

2: The user submitted the page and one of the checks at the beginning of the PHP code detected an error

 

I recall now that when I first wrote this contrib, I ran into some trouble on these pages and I never went back and finished it. My apologies.

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...