 [Skip to main content](#vessel-content) 

 

 

#   USA States in CSV export 



 

 



 

##  

 



- **[ltempest](/forum/user/1784-ltempest "View ltempest's Profile")**
- [![ltempest's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/1784-ltempest "View ltempest's Profile") Topic Author
- [ Offline](/forum/user/1784-ltempest)
 
 Less More- Posts: 237
- Thank you received: 5
- 
- 
 
 

 

 

    11 years 7 months ago [\#194319](#194319) by [ltempest](/forum/user/1784-ltempest "View ltempest's Profile")  *[USA States in CSV export](/forum/37-import-export-csv-xls/875617-usa-states-in-csv-export#194319 "-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.4.0

When I export an order as a CSV file the US State is being exported as:

state_South_Carolina_4304

How can I use the standard State shortcodes so the above would be:

SC

Are these stored in a db table somewhere I can change? I need to replicate this:


 geography.about.com/od/lists/a/stateabbreviate.htm

For each state in the database.

Thanks

Lee")* was created by *[ltempest](/forum/user/1784-ltempest "View ltempest's Profile")* 

 -- HikaShop version -- : 2.4.0  
-- Joomla version -- : 3.4.0  
  
When I export an order as a CSV file the US State is being exported as:  
  
state_South_Carolina_4304  
  
How can I use the standard State shortcodes so the above would be:  
  
SC  
  
Are these stored in a db table somewhere I can change? I need to replicate this:  
  
[ geography.about.com/od/lists/a/stateabbreviate.htm](http://geography.about.com/od/lists/a/stateabbreviate.htm)  
  
For each state in the database.  
  
Thanks  
  
Lee 

 

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2ltcG9ydC1leHBvcnQtY3N2LXhscy84NzU2MTctdXNhLXN0YXRlcy1pbi1jc3YtZXhwb3J0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

 

 

 

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)
 
 Less More- Posts: 13201
- Thank you received: 2322
- 
- 
- 
- [](http://www.kidiweb.fr)
- 
 
 

 

 

    11 years 7 months ago [\#194355](#194355) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[USA States in CSV export](/forum/37-import-export-csv-xls/875617-usa-states-in-csv-export#194355 "-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.4.0

When I export an order as a CSV file the US State is being exported as:

state_South_Carolina_4304

How can I use the standard State shortcodes so the above would be:

SC

Are these stored in a db table somewhere I can change? I need to replicate this:


 geography.about.com/od/lists/a/stateabbreviate.htm

For each state in the database.

Thanks

Lee")* 

 Hi,  
  
You could potentially replace the content of the view "order / export" in the backend template by something like: Code:

&lt;?php while(ob_get_level() &gt; 1) ob_end_clean(); $config =&amp; hikashop_config(); $format = $config-&gt;get('export_format','csv'); $separator = $config-&gt;get('csv_separator',';'); $force_quote = $config-&gt;get('csv_force_quote',1); $export = hikashop_get('helper.spreadsheet'); $export-&gt;init($format, 'hikashop_export', $separator, $force_quote); if(!empty($this-&gt;orders)){ $maxProd = 0; $productFields = null; foreach($this-&gt;orders as $order){ $nbProd = count($order-&gt;products); if($maxProd &lt; $nbProd){ $maxProd = $nbProd; if(empty($productFields)){ $productFields = array_keys(get_object_vars(reset($order-&gt;products))); } } } if($maxProd &amp;&amp; !empty($productFields)) { $first = array(); $o = reset($this-&gt;orders); foreach($o as $key =&gt; $val) { if(is_array($val)) continue; $first[] = $key; } $o = null; for($i=1;$i&lt;=$maxProd;$i++){ foreach($productFields as $field){ $first[] = 'item'.$i.'_'.$field; } } } else { $first = array_keys(get_object_vars(reset($this-&gt;orders))); } $export-&gt;writeLine($first); /* Added */ $db = JFactory::getDBO(); $db-&gt;setQuery('SELECT b.zone_namekey, b.zone_code_3 FROM '.hikashop_table('zone_link').' as a LEFT JOIN '.hikashop_table('zone').' AS b ON a.zone_child_namekey = b.zone_namekey WHERE a.zone_parent_namekey = '.$db-&gt;quote('country_United_States_of_America_223')); $usStates = $db-&gt;loadObjectList(); $stateCodes = array(); foreach($usStates as $usState){ $stateCodes[$usState-&gt;zone_namekey] = $usState-&gt;zone_code_3; } /* EO Added */ foreach($this-&gt;orders as $row){ // Let's apply the right date format... an human one! if(!empty($row-&gt;user_created)) $row-&gt;user_created = hikashop_getDate($row-&gt;user_created,'%Y-%m-%d %H:%M:%S'); if(!empty($row-&gt;order_created)) $row-&gt;order_created = hikashop_getDate($row-&gt;order_created,'%Y-%m-%d %H:%M:%S'); if(!empty($row-&gt;order_modified)) $row-&gt;order_modified = hikashop_getDate($row-&gt;order_modified,'%Y-%m-%d %H:%M:%S'); if($maxProd &amp;&amp; !empty($productFields)){ for($i=1;$i&lt;=$maxProd;$i++){ $prod =&amp; $row-&gt;products[$i-1]; foreach($productFields as $field){ $n = 'item_'.$i.'_'.$field; $row-&gt;$n = @$prod-&gt;$field; } } } /* Added */ foreach($row as $key =&gt; $value){ if(in_array($value,array_keys($stateCodes))){ $row-&gt;$key = $stateCodes[$value]; } } /* EO Added */ $export-&gt;writeLine($row); } } $export-&gt;send(); exit;



 

 

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2ltcG9ydC1leHBvcnQtY3N2LXhscy84NzU2MTctdXNhLXN0YXRlcy1pbi1jc3YtZXhwb3J0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

 

 

 

- **[ltempest](/forum/user/1784-ltempest "View ltempest's Profile")**
- [![ltempest's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/1784-ltempest "View ltempest's Profile") Topic Author
- [ Offline](/forum/user/1784-ltempest)
 
 Less More- Posts: 237
- Thank you received: 5
- 
- 
 
 

 

 

    11 years 7 months ago -  11 years 7 months ago [\#194478](#194478) by [ltempest](/forum/user/1784-ltempest "View ltempest's Profile")  Replied by *[ltempest](/forum/user/1784-ltempest "View ltempest's Profile")* on topic *[USA States in CSV export](/forum/37-import-export-csv-xls/875617-usa-states-in-csv-export#194478 "-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.4.0

When I export an order as a CSV file the US State is being exported as:

state_South_Carolina_4304

How can I use the standard State shortcodes so the above would be:

SC

Are these stored in a db table somewhere I can change? I need to replicate this:


 geography.about.com/od/lists/a/stateabbreviate.htm

For each state in the database.

Thanks

Lee")* 

 Xavier,  
thanks for the reply.  
  
Which file in the backend do you mean precisely? Can you provide the file path?  
  
I think I found it:  
  
**/administrator/components/com\_hikashop/views/order/tmpl/export.php**   
  
Thanks 

 

 Last edit: 11 years 7 months ago by [ltempest](/forum/user/1784-ltempest "View ltempest's Profile"). 

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2ltcG9ydC1leHBvcnQtY3N2LXhscy84NzU2MTctdXNhLXN0YXRlcy1pbi1jc3YtZXhwb3J0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

 

 

 

- **[ltempest](/forum/user/1784-ltempest "View ltempest's Profile")**
- [![ltempest's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/1784-ltempest "View ltempest's Profile") Topic Author
- [ Offline](/forum/user/1784-ltempest)
 
 Less More- Posts: 237
- Thank you received: 5
- 
- 
 
 

 

 

    11 years 7 months ago [\#194484](#194484) by [ltempest](/forum/user/1784-ltempest "View ltempest's Profile")  Replied by *[ltempest](/forum/user/1784-ltempest "View ltempest's Profile")* on topic *[USA States in CSV export](/forum/37-import-export-csv-xls/875617-usa-states-in-csv-export#194484 "-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.4.0

When I export an order as a CSV file the US State is being exported as:

state_South_Carolina_4304

How can I use the standard State shortcodes so the above would be:

SC

Are these stored in a db table somewhere I can change? I need to replicate this:


 geography.about.com/od/lists/a/stateabbreviate.htm

For each state in the database.

Thanks

Lee")* 

 Xavier,  
I have modified the export file in the /administrator/components/com_hikashop/views/order/tmpl/export.php location to your code but it is still not exporting the State as the three character zone version.  
  
Sorry!  
  
Lee 

 

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2ltcG9ydC1leHBvcnQtY3N2LXhscy84NzU2MTctdXNhLXN0YXRlcy1pbi1jc3YtZXhwb3J0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

 

 

 

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)
 
 Less More- Posts: 13201
- Thank you received: 2322
- 
- 
- 
- [](http://www.kidiweb.fr)
- 
 
 

 

 

    11 years 7 months ago [\#194492](#194492) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[USA States in CSV export](/forum/37-import-export-csv-xls/875617-usa-states-in-csv-export#194492 "-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.4.0

When I export an order as a CSV file the US State is being exported as:

state_South_Carolina_4304

How can I use the standard State shortcodes so the above would be:

SC

Are these stored in a db table somewhere I can change? I need to replicate this:


 geography.about.com/od/lists/a/stateabbreviate.htm

For each state in the database.

Thanks

Lee")* 

 Hi,  
  
I guess that you are using the export from the mass action, right ?  
I was thinking of the export from the orders listing interface in backend.  
  
So you have to edit the file "plugins/hikashop/massaction_order/massaction_order.php" and in the function "onProcessOrderMassActionexportCsv()"  
  
Add: Code:

/* Added */ $db = JFactory::getDBO(); $db-&gt;setQuery('SELECT b.zone_namekey, b.zone_code_3 FROM '.hikashop_table('zone_link').' as a LEFT JOIN '.hikashop_table('zone').' AS b ON a.zone_child_namekey = b.zone_namekey WHERE a.zone_parent_namekey = '.$db-&gt;quote('country_United_States_of_America_223')); $usStates = $db-&gt;loadObjectList(); $stateCodes = array(); foreach($usStates as $usState){ $stateCodes[$usState-&gt;zone_namekey] = $usState-&gt;zone_code_3; } foreach($params-&gt;elements as $k =&gt; $element){ foreach($element-&gt;address as $l =&gt; $data){ foreach($data as $m =&gt; $value){ if($m == 'address_state' &amp;&amp; in_array($value,array_keys($stateCodes))){ $params-&gt;elements[$k]-&gt;address[$l]-&gt;address_state = $stateCodes[$value]; } } } } /* EO Added */



Before: Code:

$this-&gt;massaction-&gt;_exportCSV($params);



 

 

 The following user(s) said Thank You: [admindcusa](/forum/user/37615-admindcusa "View admindcusa's Profile") 

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2ltcG9ydC1leHBvcnQtY3N2LXhscy84NzU2MTctdXNhLXN0YXRlcy1pbi1jc3YtZXhwb3J0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

 

 

 

- **[admindcusa](/forum/user/37615-admindcusa "View admindcusa's Profile")**
- [![admindcusa's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/37615-admindcusa "View admindcusa's Profile")
- [ Offline](/forum/user/37615-admindcusa)
 
 Less More- Posts: 8
- Thank you received: 0
- 
- 
 
 

 

 

    11 years 2 months ago [\#210150](#210150) by [admindcusa](/forum/user/37615-admindcusa "View admindcusa's Profile")  Replied by *[admindcusa](/forum/user/37615-admindcusa "View admindcusa's Profile")* on topic *[USA States in CSV export](/forum/37-import-export-csv-xls/875617-usa-states-in-csv-export#210150 "-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.4.0

When I export an order as a CSV file the US State is being exported as:

state_South_Carolina_4304

How can I use the standard State shortcodes so the above would be:

SC

Are these stored in a db table somewhere I can change? I need to replicate this:


 geography.about.com/od/lists/a/stateabbreviate.htm

For each state in the database.

Thanks

Lee")* 

 And this is why I've bought 3 copies of your shopping cart software Hikashop Business for my clients and getting ready to purchase another one soon for another client. It is your customer support that defines how good your product is.  
Thank you for your help.  
Jonathan  
Digital Creations USA, Inc. 

 

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2ltcG9ydC1leHBvcnQtY3N2LXhscy84NzU2MTctdXNhLXN0YXRlcy1pbi1jc3YtZXhwb3J0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

 

 

 



 

 

 



 

 



   Board Categories HikaShop- Install &amp; Update- Product &amp; Category Display- Content Creation- Sales and Orders- - Orders management- - Reports &amp; Statistics- Customers- Checkout- Payment Methods- Shipping Methods- Import &amp; Export (CSV, XLS…)- Specific Features- - Affilation- - Taxes- - Wishlist- - Vote- - Carousel &amp; Slider- - Mass Actions- - Filters &amp; Search- - Discount &amp; Coupon- - Feature Request- Integrations- Showcase- General Talk about HikaShop- Development- - HikaShop 3.0 Beta- Translation- Commercial Jobs HikaShop Components- HikaMarket- - Market: Feature requests- - Market: How to?- - Market: Bug Report- HikaSerial- - General talk about HikaSerial- - Serial: Bug Report- - Serial: How to?- - Support en Français de HikaSerial (French Support)- - HikaSubscription- HikaAuction- - Auction: Feature requests- - Auction: How to?- - Auction: Bug report Hikashop around the world- Support en Français (French Support)- Russian- - FAQ. Курс выживания с Hikashop. Частые вопросы и о- - Расширения Hikashop- - Наши сайты на Hikashop- 日本語版サポート(Japanese Support)- Thai- German Archives- Bug Report- How to?







[](/forum/topics/feed/mode-topics?format=feed&type=rss)



 Time to create page: 0.296 seconds 

 

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

 

  [](#top)