Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Change state


katonboard

Recommended Posts

I would like the state presented as more than 2 characters in the billing and delivery addresses. Does anyonw know where this is defined? It is currently set to show only the first 2 characters of whatever is typed. I would like to to show more.

 

This field is in the english.php

define('ENTRY_STATE', 'State/Province:');

 

But I would like to find where the number of characters displayed is defined.

 

Does anyone quickly know or can point me in the right direction.

Thank you,

Kat

Link to comment
Share on other sites

Something is wrong here. Where are you seeing only the first two characters displayed?

 

I started to type a longer answer about address formats (which have significant problems in the stock osC), but I think you're seeing something else.

Link to comment
Share on other sites

Something is wrong here.  Where are you seeing only the first two characters displayed? 

 

I started to type a longer answer about address formats (which have significant problems in the stock osC), but I think you're seeing something else.

 

Thanks Steve,

 

What I see in the checkout for both the billing and shipping address would be...

Example

 

Fred Bog

2 Fish Pl

Sydney

NS, 2345, Australia

I would like to have the NS as NSW.

 

Any ideas?

Kat

Link to comment
Share on other sites

Thanks Steve,

 

What I see in the checkout for both the billing and shipping address would be...

Example

 

Fred Bog

2 Fish Pl

Sydney

NS, 2345, Australia

I would like to have the NS as NSW.

 

Any ideas?

Kat

 

Ah, I had to do that myself for Australia--the World Zones contribution has some errors, I think. Anyway, if you have phpmyadmin just search the zones table for zone_country_id of 13...then edit the zone_code fields. While we're at it, can you confirm if these are standard codes for Oz?

 

AC

NSW

NT

QLD

SA

TA

VI

WA

"Buy the ticket, take the ride..." -HST

Link to comment
Share on other sites

I too found the World Zones contribution troublesome, but I haven't looked at it in a year or so.

 

Let me look tonight at the changes I've made to my store - I know that Australia was one of the countries I worked at getting the correct address format for.

Link to comment
Share on other sites

Ok, now I get it. Yes, the World Zones contribution has incorrect abbreviations for Australia's territories. (And was, last I looked, missing a majority of UK zones, and had errors for many other countries...)

 

The International Postal Union is my reference for addressing formats. If you go there, you will see that the OSC default format 1 is incorrect for Australia. There is also a link to AusPost Digging into that site reveals the following list:

 

State/Territory Abbrev

Australian Capital Territory ACT

New South Wales NSW

Northern Territory NT

Queensland QLD

South Australia SA

Tasmania TAS

Victoria VIC

Western Australia WA

 

For my store, I modified tep_address_format to provide for a couple of additional formatting options (such as upper case city). I also defined about a dozen address formats for countries we might ship to. The one I have for Australia is:

 

'$firstname $lastname$cr$streets$cr$city, $statezone $postcode$cr$country'

 

$statezone is a field I added for the abbreviation.

 

The real problem for you is that table orders has nothing but "state". You would have to first do a lookup of the country in the countries table to get the country id, and then look up in the zones table to get the zone id and the zone code (abbreviation). For my store, I carry around the country and zone code (if any) with the order, but you can do it with lookups too. (I probably should have done it that way myself, in hindsight.)

Link to comment
Share on other sites

  • 2 weeks later...
$statezone is a field I added for the abbreviation.

 

Hi stevel, this is exactly what I am trying to do at the moment. As per the guidelines on http://www.bitboost.com/ref/international-...ss-formats.html, when shipping to the USA, the abbreviation is needed for the state.

However oscommerce shows the state name in the delivery address everywhere.

 

Where did you define $statezone, can you contribute the function you used to get this into your address formatting?

 

What else needs to be done apart from setting up the new format in the address_format table?

Link to comment
Share on other sites

Here is my revised tep_address_format routine. But this works from admin on orders only because I modified the store code to record the zone_ids in the order record. By default, the zone_id is discarded once the order is recorded.

 

As I mentioned earlier, you could reconstruct the zone_id with the proper queries.

 

Note also the $uccity variable, as many countries want you to upcase the city name.

 

I've thought on and off of creating a contribution to manage address formats, but it would be better to just create a set of correct formats and load it in, because there's not really a lot of point in individual store owners making changes here. That's a LOT of work. It would also require enhancements to preserve or recover (better) the zone IDs. (I also don't like the way the address format is stored in the order - this should be queried based on the country!)

 

  function tep_address_format($address_format_id, $address, $html, $boln, $eoln) {
   $address_format_query = tep_db_query("select address_format as format from " . TABLE_ADDRESS_FORMAT . " where address_format_id = '" . (int)$address_format_id . "'");
   $address_format = tep_db_fetch_array($address_format_query);

   $company = tep_output_string_protected($address['company']);
   if (isset($address['firstname']) && tep_not_null($address['firstname'])) {
     $firstname = tep_output_string_protected($address['firstname']);
     $lastname = tep_output_string_protected($address['lastname']);
   } elseif (isset($address['name']) && tep_not_null($address['name'])) {
     $firstname = tep_output_string_protected($address['name']);
     $lastname = '';
   } else {
     $firstname = '';
     $lastname = '';
   }
   $street = tep_output_string_protected($address['street_address']);
   $suburb = tep_output_string_protected($address['suburb']);
   $city = tep_output_string_protected($address['city']);
   $state = tep_output_string_protected($address['state']);
   $statezone = $state;
   if (isset($address['country_id']) && tep_not_null($address['country_id'])) {
     $country = tep_get_country_name($address['country_id']);

     if (isset($address['zone_id']) && tep_not_null($address['zone_id'])) {
       $statezone = tep_get_zone_code($address['country_id'], $address['zone_id'], $state);
       $state = tep_get_zone_name($address['country_id'], $address['zone_id'], $state);
     }
   } elseif (isset($address['country']) && tep_not_null($address['country'])) {
     $country = tep_output_string_protected($address['country']);
   } else {
     $country = '';
   }
   $postcode = tep_output_string_protected($address['postcode']);
   $zip = $postcode;

   if ($html) {
// HTML Mode
     $HR = '<hr>';
     $hr = '<hr>';
     if ( ($boln == '') && ($eoln == "\n") ) { // Values not specified, use rational defaults
       $CR = '<br>';
       $cr = '<br>';
       $eoln = $cr;
     } else { // Use values supplied
       $CR = $eoln . $boln;
       $cr = $CR;
     }
   } else {
// Text Mode
     $CR = $eoln;
     $cr = $CR;
     $HR = '----------------------------------------';
     $hr = '----------------------------------------';
   }

   $statecomma = '';
   $streets = $street;
   if ($suburb != '') $streets = $street . $cr . $suburb;
   if ($country == '') $country = tep_output_string_protected($address['country']);
   if ($state != '') $statecomma = $state . ', ';
   $uccity = strtoupper($city);

   $fmt = $address_format['format'];
   eval("\$address = \"$fmt\";");

   if ( (ACCOUNT_COMPANY == 'true') && (tep_not_null($company)) ) {
     $address = $company . $cr . $address;
   }

   return $address;
 }

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...