HikaShop GeoLocation data display on Order page in admin area

  • Posts: 2
  • Thank you received: 0
7 years 2 months ago #277249

Hello,

I can't understand how to display the HikaShop GeoLocation data (from HikaShop GeoLocation plugin) on order page in admin area.

I found this template:
/administrator/components/com_hikashop/views/order/tmpl/form.php

Where I can see:

<tr>
	<td class="key">
		<?php echo JText::_( 'IP' ); ?>
	</td>
	<td><?php
		echo $this->order->order_ip;
		if(!empty($this->order->geolocation) && $this->order->geolocation->geolocation_country!='Reserved'){
			echo ' ( '.$this->order->geolocation->geolocation_city.' '.$this->order->geolocation->geolocation_state.' '.$this->order->geolocation->geolocation_country.' )';
		}
	?></td>
</tr>

But when I open an order from the Orders page:
/administrator/index.php?option=com_hikashop&ctrl=order

via this link:
/administrator/index.php?option=com_hikashop&ctrl=order&task=edit&cid[]=X

the other order view template is used, not form.php.

I have two questions:
  1. how can I display GeoLocation data on order edit page in admin area?
  2. where form.php order view template is used?

The HikaShop GeoLocation plugin params:
  1. Orders geolocation = Yes
  2. Customers geolocation = Yes
  3. Geolocation service = Both
  4. API key is filled

I can see GeoLocation data on user edit page in admin area:
/administrator/index.php?option=com_hikashop&ctrl=user&task=edit&cid=X

for example:
IP X.X.X.X ( Chula Vista CA United States )

Thus, the plugin works fine and successfully store the data.

Thanks in advance!

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
7 years 2 months ago #277278

Hi,

You're right, the new order edition view is missing the IP/geolocation data which was displayed before in the old order edition view that you found.
Add the code:

function onHikashopBeforeDisplayView(&$view) {
		$app = JFactory::getApplication();
		if(!$app->isAdmin())
			return true;

		if(empty($view->order->order_ip))
			return;

		$viewName = $view->getName();
	 	$layoutName = $view->getLayout();
		if($viewName != 'order' || $layoutName != 'show')
			return true;

		$data = $view->order->order_ip;
		if(!empty($view->order->geolocation) && $view->order->geolocation->geolocation_country!='Reserved'){
			$data .= ' ( '.$view->order->geolocation->geolocation_city.' '.$view->order->geolocation->geolocation_state.' '.$view->order->geolocation->geolocation_country.' )';
		}

		$view->extra_data['user']['ip'] = array(
			'title' => JText::_( 'IP' ),
			'data' => $data
		);
	}
before the line:
function onAfterOrderCreate(&$order,&$send_email){
in the file plugins/hikashop/geolocation/geolocation.php and that should add back the geolocation data to the new edition view too.
When changing the code of the view to the new one, we added the triggers so that the plugins could themselves add their data to the view, but we forgot to update the geolocation plugin to add its data through the trigger.

Thanks for the catch !

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

  • Posts: 2
  • Thank you received: 0
7 years 2 months ago #277317

Thank you, everything works fine now.

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

Time to create page: 0.058 seconds
Powered by Kunena Forum