state_ and country_ before state and country name

  • Posts: 75
  • Thank you received: 1
9 years 10 months ago #186924

-- HikaShop version -- : 2.3.5
-- Joomla version -- : 3.3.6
-- Browser(s) name and version -- : latest IE, FF and Chrome

When I look in the csv file from the mass action export is see that the states and country names are not the real names. It looks that name used in the database is shown. See image.

Is this normal?



Kind regards,

Wilfried

Attachments:
Last edit: 9 years 10 months ago by wilfried. Reason: SOLVED

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

  • Posts: 13201
  • Thank you received: 2322
9 years 10 months ago #186977

Hi,

These are the values stored in the #__hikashop_address table, so the mass action is get this value directly from Database.

You can potentially use a regex in order to keep only the middle part (the english name).
For that you can edit the file "plugins/hikashop/massaction_order/massaction_order.php" and in the function "onProcessOrderMassActionexportCsv" add:

		foreach($params->elements as $i => $element){
			foreach($element->address as $j => $row){
				if(isset($row->address_state)){
					$row->address_state = preg_replace('#^[^_]*_#','',$row->address_state);
					$row->address_state = preg_replace('#_*[0-9]#','',$row->address_state);
				}
				if(isset($row->address_country)){
					$row->address_country = preg_replace('#^[^_]*_#','',$row->address_country);
					$row->address_country = preg_replace('#_*[0-9]#','',$row->address_country);
				}
			}
		}
after:
$params = $this->massaction->_displayResults('order',$elements,$action,$k);

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

  • Posts: 75
  • Thank you received: 1
9 years 10 months ago #187011

Hello Xavier,

Clear, I'll do that, thanks for you quick response.

In the last few days I have added some changes to massaction_order.php and I will add some more to get some other things corrected. I was wondering what happens when there is a new version of Hikashop do I have to add all those changes again. What is the policy of hikashop when updating to a new version and how often is hikashop being updated?

Kind regards,

Wilfried

Last edit: 9 years 10 months ago by wilfried. Reason: spelling errors

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

  • Posts: 13201
  • Thank you received: 2322
9 years 10 months ago #187024

Hi,

When updating you will indeed lose your modiications.
What I suggest is to copy that plugin, rename it, and do the correct renaming in the files.

Then install it via the Joomla extensions manager, publish it and unpublish our plugin.
This way you will never lose your changes.

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

  • Posts: 75
  • Thank you received: 1
9 years 10 months ago #187119

Ok I'll look into the procedure how to make a plugin from a php file, but isn't it so that when hikashop calls massaction_order.php it has to be that name exactly? That because I have made several changes massaction_order.php.

Your way seems much cleaner and better but if I rename massaction_order.php to WR-massaction_order.php how does the export routine know that it has to use WR-massaction_order.php when I want to do mass actions on orders.

Kind regards Wilfried

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
9 years 10 months ago #187144

Hi,

When Xavier says that you need to rename the plugin, it involves more than just changing the name of the php file. The xml file has to be renamed as well, the folder as well, and you need to edit both xml and php files to change the name as well (in the php file, it's mainly the class name at the beginning). Then you can zip the files and install it via the Joomla installer and activate it so that Joomla can call it when HikaShop trigger the triggers of the mass actions.

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

  • Posts: 75
  • Thank you received: 1
9 years 10 months ago #187207

OK Thanks, I already thought something llike that.

And what makes the trigger with Hikashop. How does Hikashop know that it should use the new plugin instead of massaction.php?
Do I have to change something in the php code to let Hikashop use massaction_order_mine.php instead of massaction_order.php ?

Kind regards Wilfried

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

  • Posts: 13201
  • Thank you received: 2322
9 years 10 months ago #187260

Hi,

After renaming the php and xml files and their content, you just have to unpublish our plugin and enable yours.
This way you are sure that only your plugin will be used.

Your plugin is used when this kind of function is called by hikashop:
onProcessOrderMassActionupdateValues

It is automatic.

The following user(s) said Thank You: wilfried

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

  • Posts: 75
  • Thank you received: 1
9 years 10 months ago #187262

Now I understand, thanks!.

kind regards, WIlfried

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

  • Posts: 517
  • Thank you received: 8
  • Hikashop Business
9 years 2 months ago #212914

Hi, I am looking to export the shipping address details via mass action and found this thread wanting the similar information, however when entering the change some of the exports still have underscores and there are now no spaces in 'United Kingdom' and also underscores in some of the 'state' export as well.

shipping_address_state shipping_address_country
New_Jersey United_States_of_America
New_Jersey United_States_of_America
New_Jersey United_States_of_America
Lisboa Portugal
Leicestershire UnitedKingdom
Hampshire UnitedKingdom
Hertfordshire UnitedKingdom
WestMidlands UnitedKingdom
Middlesex UnitedKingdom
London UnitedKingdom
Kent UnitedKingdom
Dorset UnitedKingdom
WestYorkshire UnitedKingdom
Manchester UnitedKingdom
Cleveland UnitedKingdom
Zagreb Croatia
Rhondda_Cynon_Taf UnitedKingdom

Is there an easier way to export shipping addresses as they are laid out in the 'order'? this is needed for a new bar code system introduced by Royal Mail in the UK to be printed on to address labels.

thanks

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

  • Posts: 13201
  • Thank you received: 2322
9 years 2 months ago #212920

Hi,

Please try that code instead:

		foreach($params->elements as $i => $element){
			foreach($element->address as $j => $row){
				if(isset($row->address_state)){
					$row->address_state = preg_replace('#^[^_]*_#','',$row->address_state);
					$row->address_state = preg_replace('#_*[0-9]$#','',$row->address_state);
					$row->address_state = str_replace('_',' ',$row->address_state);
				}
				if(isset($row->address_country)){
					$row->address_country = preg_replace('#^[^_]*_#','',$row->address_country);
					$row->address_country = preg_replace('#_*[0-9]$#','',$row->address_country);
					$row->address_country = str_replace('_',' ',$row->address_country);
				}
			}
		}
We don't have ported this modification on our end yet, but it is on our todo list.

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

  • Posts: 517
  • Thank you received: 8
  • Hikashop Business
9 years 2 months ago #213010

Hi, Works for some but not others and now leaving numbers on the end... see below.
order_id shipping_address_state shipping_address_country
18223 New Jersey 429 United States of America 22
18224 New Jersey 429 United States of America 22
18225 New Jersey 429 United States of America 22
18296 Lisboa 300 Portugal 17
18306 Leicestershire 414 UnitedKingdom 77840086
18307 Hampshire 411 UnitedKingdom 77840086
18309 Hertfordshire 412 UnitedKingdom 77840086
18310 WestMidlands 104986208 UnitedKingdom 77840086
18311 Middlesex 135968147 UnitedKingdom 77840086
18312 London 414 UnitedKingdom 77840086
18313 Kent 413 UnitedKingdom 77840086
18314 Dorset 409 UnitedKingdom 77840086
18315 WestYorkshire 76284918 UnitedKingdom 77840086
18316 Manchester 415 UnitedKingdom 77840086
18318 Cleveland 200498208 UnitedKingdom 77840086
18319 Zagreb 108 Croatia 5
18320 Rhondda Cynon Taf 419 UnitedKingdom 77840086
18321 Devon 408 UnitedKingdom 77840086
18322 Aberdeenshire 402 UnitedKingdom 77840086
18323 Hampshire 411 UnitedKingdom 77840086
18324 Berkshire 111061387 UnitedKingdom 77840086
18325 Dumfries and Galloway 408 UnitedKingdom 77840086
18326 Hampshire 411 UnitedKingdom 77840086
18327 94 China 4

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

  • Posts: 13201
  • Thank you received: 2322
9 years 2 months ago #213030

Hi,

Just to clarify a bit the situation, we will not use that code when we will implement that feature.
That code is a temporary code to manage that situation, but the final code will use database queries to get the desired data from the zone table.

Here is a new version of that temporary code, not tested.

		foreach($params->elements as $i => $element){
			foreach($element->address as $j => $row){
				if(isset($row->address_state)){
					$row->address_state = str_replace('_',' ',str_replace('state_','',preg_replace('#_[0-9]*$#','',$row->address_state)));
				}
				if(isset($row->address_country)){
					$row->address_country = str_replace('_',' ',str_replace('country_','',preg_replace('#_[0-9]*$#','',$row->address_country)));
				}
			}
		}

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

Time to create page: 0.105 seconds
Powered by Kunena Forum