Skip to main content

2 letter US state code

More
10 years 7 months ago #231268 by edocif
-- HikaShop version -- : 2.6.1
-- Joomla version -- : 3.4.8
-- PHP version -- : 5.5
-- Browser(s) name and version -- : google chorm

i am trying to alter the display of the adress for fax to EDI. two requirements is the 3 digit country code and the 2 digit state code.

I was able to do the country code with the code shown below
Code:
<?php $address = $this->params->get('address'); echo $address->address_country_code_3; ?>

so naturally i tried
Code:
<?php $address = $this->params->get('address'); echo $address->address_state_code_2; ?>

but that returned zero data so i reverted the code back to what was working
Code:
<?php /** * @package HikaShop for Joomla! * @version 2.6.0 * @author hikashop.com * @copyright (C) 2010-2015 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?> {address_company} {address_title} {address_firstname} {address_lastname} {address_street} {address_city} {address_state} {address_post_code} <?php $address = $this->params->get('address'); echo $address->address_country_code_3; ?> <?php echo JText::sprintf('TELEPHONE_IN_ADDRESS','{address_telephone}');?>

I need {address_state} to change out to the address_state_code_2 but need to know what the proper reference would be. Thank you in advance for your help

Please Log in or Create an account to join the conversation.

More
10 years 7 months ago #231271 by edocif
Replied by edocif on topic 2 letter US state code
figured it out in my case in the USA the state code was under code 3 letters so i just had to put address_state_code_3 and it worked like a charm. see my final address_template.php from Display > Views (my custom template)
Code:
<?php /** * @package HikaShop for Joomla! * @version 2.6.0 * @author hikashop.com * @copyright (C) 2010-2015 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?> {address_company} {address_title} {address_firstname} {address_lastname} {address_street} {address_city} <?php $address = $this->params->get('address'); echo $address->address_state_code_3; ?> {address_post_code} <?php $address = $this->params->get('address'); echo $address->address_country_code_3; ?>{} <?php echo JText::sprintf('TELEPHONE_IN_ADDRESS','{address_telephone}');?>

Please Log in or Create an account to join the conversation.

More
4 years 10 months ago #336673 by brentwilliams2
BIG thank you for this!

And to add for others, you can use this in the admin area under System > Configuration > Checkout > Address & Shipping:
Code:
{address_firstname} {address_lastname} {address_street} {address_city}, <?php $address = $this->params->get('address'); echo $address->address_state_code_3; ?> {address_post_code}

Please Log in or Create an account to join the conversation.

Time to create page: 0.270 seconds
Powered by Kunena Forum