Page 1 of 1

How do I change US states to abbreviated form?

Posted: Sun Oct 16, 2016 6:36 pm
by OpenCustomer
I need to change the US States from long names to abbreviated form in checkout drop-down list such as from Alabama to AL. I want that change would be also written in the orders, order confirmation, etc. in customer`s addresses.

I tried to change this in oc_zone but didn't help. It only changed in the admin zones page.

How do I do this? Is there a main place to be able to make that change?

Thanks,
sa

Re: How do I change US states to abbreviated form?

Posted: Sun Oct 16, 2016 7:18 pm
by fido-x
Have a look in the following files:
  • catalog/view/theme/default/template/checkout/payment_address.tpl
    catalog/view/theme/default/template/checkout/shipping_address.tpl
    catalog/view/theme/default/template/checkout/guest.tpl
    catalog/view/theme/default/template/checkout/guest_shipping.tpl
Find:

Code: Select all

html += '>' + json['zone'][i]['name'] + '</option>';
and change to:

Code: Select all

html += '>' + json['zone'][i]['iso_code_2'] + '</option>';

Re: How do I change US states to abbreviated form?

Posted: Sun Oct 16, 2016 10:41 pm
by OpenCustomer
I am on Journal theme. I edited the both default and Journal theme files as you suggested but didn't help. I still read the long form of the US States in the drop-down in checkout page.

Any more advice please?

Re: How do I change US states to abbreviated form?

Posted: Mon Oct 17, 2016 10:35 am
by fido-x
Sorry, my bad. I was looking at the country code and not the zone code. Use the following code in the aforementioned files:

Code: Select all

html += '>' + json['zone'][i]['code'] + '</option>';
That should cover the orders.

For customer account information, you'll also need to make the same change to:
  • catalog/view/theme/default/template/account/address_form.tpl
    catalog/view/theme/default/template/account/register.tpl

Re: How do I change US states to abbreviated form?

Posted: Mon Oct 17, 2016 11:57 pm
by OpenCustomer
No Sir, didn't change. Still reading long form of States.

Re: How do I change US states to abbreviated form?

Posted: Tue Oct 18, 2016 6:48 am
by fido-x
Refresh your modifications.

Re: How do I change US states to abbreviated form?

Posted: Tue Dec 06, 2016 10:06 am
by rexa
I'm having the same issue here, and I know this has been an ongoing thing with US opencart users. I implemented the modifications as suggested on this thread, but all they do is change the state abbreviations in the options selector, but does not save as such to the actual addressbook entry.

Re: How do I change US states to abbreviated form?

Posted: Thu Dec 08, 2016 2:58 pm
by rexa
Nevermind. I created my own VQmod to reduce the zone_id character limitations and I renamed the zone_ids for the states as abbreviations instead of leaving them as long names.

The problem I found with the previous coding suggesting is that it only shows them as drop-down menu options but not effectively saving them as such abbreviations - just an fyi