2 letter US state code

  • Posts: 13
  • Thank you received: 0
8 years 1 month ago #231268

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

<?php
$address = $this->params->get('address');
echo $address->address_country_code_3; ?>

so naturally i tried
<?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
<?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.

  • Posts: 13
  • Thank you received: 0
8 years 1 month ago #231271

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)

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

  • Posts: 78
  • Thank you received: 5
  • Hikashop Business
2 years 5 months ago #336673

BIG thank you for this!

And to add for others, you can use this in the admin area under System > Configuration > Checkout > Address & Shipping:

{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.066 seconds
Powered by Kunena Forum