Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Save US State as a initials in database instead of full name

Save US State as a initials in database instead of full name

Locked

Views: 1,273

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
29 Mar 2010, 4:46 PM
#1
bellorusha avatar

bellorusha

New Zenner

Join Date:
Mar 2010
Posts:
4
Plugin Contributions:
0

Save US State as a initials in database instead of full name

Hello, I Intergrated the zencart database with our Fedex and UPS software, but they can only match state with initials in it (NY, CA, etc..), but zencart saves the entire name of the state (New York, California, etc..), is there a place I can change it?

thanks

29 Mar 2010, 6:40 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Save US State as a initials in database instead of full name

Can't you map to the zone_code in the zones table?

29 Mar 2010, 6:43 PM
#3
bellorusha avatar

bellorusha

New Zenner

Join Date:
Mar 2010
Posts:
4
Plugin Contributions:
0

Re: Save US State as a initials in database instead of full name

it doesn't work like this, it wants to have this info in delevery_state field

29 Mar 2010, 7:40 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Save US State as a initials in database instead of full name

You would have to customize the orders class to use a different field for the state ...

Open the order.php class file and do a search on: state

and you can see how it is currently being applied and if you look for where you can change it to the countries_iso_code_2 instead ...

30 Mar 2010, 2:29 PM
#5
bellorusha avatar

bellorusha

New Zenner

Join Date:
Mar 2010
Posts:
4
Plugin Contributions:
0

Re: Save US State as a initials in database instead of full name

would you be so kind and tell me if that is correct change for it?

iso_code_2' => $shipping_address->fields['countries_iso_code_2'],

to

iso_code_2' => $shipping_address->fields['countries_name'],

30 Mar 2010, 3:12 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Save US State as a initials in database instead of full name

You need to add the zone_code on the select for shipping:

    $shipping_address_query = "select ab.entry_firstname, ab.entry_lastname, ab.entry_company,
                                    ab.entry_street_address, ab.entry_suburb, ab.entry_postcode,
                                    ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id,
                                    c.countries_id, c.countries_name, c.countries_iso_code_2,
                                    c.countries_iso_code_3, c.address_format_id, ab.entry_state[B],
                                    z.zone_code[/B]
                                   from " . TABLE_ADDRESS_BOOK . " ab
                                   left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)
                                   left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id)
                                   where ab.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                                   and ab.address_book_id = '" . (int)$_SESSION['sendto'] . "'";

The you can try to use it on the build of the delivery:

    $this->delivery = array('firstname' => $shipping_address->fields['entry_firstname'],
                            'lastname' => $shipping_address->fields['entry_lastname'],
                            'company' => $shipping_address->fields['entry_company'],
                            'street_address' => $shipping_address->fields['entry_street_address'],
                            'suburb' => $shipping_address->fields['entry_suburb'],
                            'city' => $shipping_address->fields['entry_city'],
                            'postcode' => $shipping_address->fields['entry_postcode'],
                            [B]'state' => ((zen_not_null($shipping_address->fields['zone_code'])) ? $shipping_address->fields['zone_code'] : $shipping_address->fields['zone_name']),[/B]
                            'zone_id' => $shipping_address->fields['entry_zone_id'],
                            'country' => array('id' => $shipping_address->fields['countries_id'], 'title' => $shipping_address->fields['countries_name'], 'iso_code_2' => $shipping_address->fields['countries_iso_code_2'], 'iso_code_3' => $shipping_address->fields['countries_iso_code_3']),
                            'country_id' => $shipping_address->fields['entry_country_id'],
                            'format_id' => (int)$shipping_address->fields['address_format_id']);

And test if this can work for you ...

I have not tested it on everything so you really want to test this change ...

30 Mar 2010, 3:30 PM
#7
bellorusha avatar

bellorusha

New Zenner

Join Date:
Mar 2010
Posts:
4
Plugin Contributions:
0

Re: Save US State as a initials in database instead of full name

It worked, thank you very much. :)

30 Mar 2010, 3:40 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Save US State as a initials in database instead of full name

Glad that worked for you ... be sure you do numerous tests to make sure it doesn't cause issues on other countries ...