Exporting Address state and country

  • Posts: 228
  • Thank you received: 4
  • Hikashop Business
5 years 6 months ago #298717

-- HikaShop version -- : 4.0.0

Hello,
I'm using CSVI Improved to setup a custom export of customer orders as I need to rename the field titles and merge some fields together to make the order processing smoother and quicker once the CSV is generated.

However when I export the shipping_address_state and the shipping_address_country fields it is exporting as so:

state_Cambridgeshire_4062

country_United_Kingdom_222

I do not need the additional text either side of the underscores and only need the text in between the underscores.

How can I remove this additional text stored in the HikaShop database tables?

Thanks

Lee

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

  • Posts: 81484
  • Thank you received: 13062
  • MODERATOR
5 years 6 months ago #298719

Hi,

You can't. These are the keys of the zones. That way, when you change the name of a zone (or we update it because something changed), the users who previously had that zone selected will automatically get that new name in their address and the zone restrictions in shipping/payment methods, etc will still work with the old addresses.
The only thing that can be done is for the CSVi export to convert the keys into the names dynamically, like the HikaShop export functions do. So I would recommend to contact the support of CSVi and see with them what can be done to do that.

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

  • Posts: 1119
  • Thank you received: 114
5 years 6 months ago #298731

Hi,

In case it will help i would like to note that CSVI component has brilliant plugin where you can find and replace fields. Please check my screenshot attached. We do replace country by it's ID or whatever we need so you could do same for each state or country.



Hope that helps.

Regards

Attachments:

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

  • Posts: 228
  • Thank you received: 4
  • Hikashop Business
5 years 6 months ago #298763

kyratn,
Thanks for your reply. I did find the Find / Replace plugin and I'm able to setup an action to remove the 'state_' and 'country_' prefix to each of the fields. This works well, however it is the text after the state/country which begins with the _underscore and then has a series of numbers.

Because my client ships to countries around the world I would need to create possibly hundreds of actions to cover every state within each country, for instance just for the United Kingdom there are 48 counties alone. Multiply this for countries around the world and the number of actions would be huge!

Is there no find / replace action I can use so that any text that appears after the underscore is removed, I tried using _* but that then replaced everything as it applies to the entire text!

I'm not a PHP / MySql guru but would setting up nine actions that would use _1* to _9* as the find / replace option work?

Thanks

Lee

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

  • Posts: 228
  • Thank you received: 4
  • Hikashop Business
5 years 6 months ago #298783

OK so I found the solution on my own, by setting the Find / Replace to use Regular Expression and then setting entering this into the search box:

/\_[0-9]*/

With an empty replace box, the underscore and number after the county / state / country are successfully removed.

Combine this with another rule to remove both state_ and country_ from the beginning and now the exported data is 'cleaned' and the correct data is exported.

Lee

Last edit: 5 years 6 months ago by ltempest. Reason: solved
The following user(s) said Thank You: kyratn

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

Time to create page: 0.083 seconds
Powered by Kunena Forum