Iframing specific dashboard components

  • Posts: 20
  • Thank you received: 0
6 years 5 months ago #293965

-- HikaShop version -- : 3.4.0 Business
-- Joomla version -- : 3.8.8
-- PHP version -- : 7.x
-- Browser(s) name and version -- : chrome / firefox
-- Error-message(debug-mod must be tuned on) -- : n/a

Is there any feasible way to iframe (or otherwise display) the #hikashop_dashboard_stat_last_orders div?
I need this specific information to show up on another related dashboard site I'm building for the client (who is using hikashop business).
They want an 'all-in-1' page, so they don't have to go to the joomla backend of the site.

any suggestions are welcome.
thanks.

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
6 years 5 months ago #293966

Hi,

You can do it like that:

if(!defined('DS'))
	define('DS', DIRECTORY_SEPARATOR);
				if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')) return true;
$statisticsClass = hikashop_get('class.statistics');
$statisticsClass->display(array('last_orders' => array(
			'slot' => 2,
			'order' => 2,
			'published' => 1,
			'container' => 1,
			'class' => 'hkc-lg-8 hkc-sm-12',
			'type' => 'dynamic',
			'label' => JText::_('HIKA_STATS_LAST_ORDERS'),
			'vars' => array(
				'COUNTER' => 6
			),
			'prefix' => '<table style="width:100%" class="table table-striped table-hover table-bordered"><thead><tr><th>'.JText::_('ORDER_NUMBER').'</th><th>'.JText::_('ORDER_STATUS').'</th><th>'.JText::_('CUSTOMER').'</th><th>'.JText::_('DATE').'</th><th>'.JText::_('PRICE').'</th></thead><tbody>',
			'dynamic' => '<tr><td>{order_number:order_link}</td><td>{order_status:order_status}</td><td>{user_email}</td><td>{order_created:date}</td><td>{order_full_price:price}</td></tr>',
			'suffix' => '</tbody></table>',
			'format' => 'text',
			'query' => array(
				'get' => 'list',
				'select' => 'hk_order.*, hk_user.*, hk_order.order_currency_id as currency',
				'tables' => array(
					hikashop_table('order') . ' AS hk_order',
					'INNER JOIN '.hikashop_table('user').' AS hk_user ON hk_order.order_user_id = hk_user.user_id'
				),
				'filters' => array(
					'order_type' => 'hk_order.order_type = '.$order_type.''
				),
				'order' => 'hk_order.order_created DESC',
				'limit' => '{COUNTER}'
			)
		)));
That should work anywhere (in any PHP file) on a Joomla website with HikaShop if Joomla is already loaded.

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

  • Posts: 20
  • Thank you received: 0
6 years 5 months ago #293984

Any way to do it from another website if you have the Jooma creds for the one you are targeting?

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
6 years 5 months ago #293992

Hi,

Use this code in a system plugin that you install on your Joomla website with the trigger onAfterRoute and check specific parameters in the URL before that code to make sure that the plugin is being called and check a password or something in the URL.
Then, simply use that URL in an iframe on that other website.
So it's possible if you're a developer and write a bit of code.

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

  • Posts: 20
  • Thank you received: 0
6 years 5 months ago #294279

I took that code you gave me and created a hidden page w/ an article (on the site using Hika Business).
In the article I pasted the code, and I have DirectPHP (and Sourcerer) plugin installed on the site, but the code is not yielding the dashboard component.
Is there anything else I'd need to do?

{source}
<?php
if(!defined('DS'))
	define('DS', DIRECTORY_SEPARATOR);
				if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')) return true;
$statisticsClass = hikashop_get('class.statistics');
$statisticsClass->display(array('last_orders' => array(
			'slot' => 2,
			'order' => 2,
			'published' => 1,
			'container' => 1,
			'class' => 'hkc-lg-8 hkc-sm-12',
			'type' => 'dynamic',
			'label' => JText::_('HIKA_STATS_LAST_ORDERS'),
			'vars' => array(
				'COUNTER' => 6
			),
			'prefix' => '<table style="width:100%" class="table table-striped table-hover table-bordered"><thead><tr><th>'.JText::_('ORDER_NUMBER').'</th><th>'.JText::_('ORDER_STATUS').'</th><th>'.JText::_('CUSTOMER').'</th><th>'.JText::_('DATE').'</th><th>'.JText::_('PRICE').'</th></thead><tbody>',
			'dynamic' => '<tr><td>{order_number:order_link}</td><td>{order_status:order_status}</td><td>{user_email}</td><td>{order_created:date}</td><td>{order_full_price:price}</td></tr>',
			'suffix' => '</tbody></table>',
			'format' => 'text',
			'query' => array(
				'get' => 'list',
				'select' => 'hk_order.*, hk_user.*, hk_order.order_currency_id as currency',
				'tables' => array(
					hikashop_table('order') . ' AS hk_order',
					'INNER JOIN '.hikashop_table('user').' AS hk_user ON hk_order.order_user_id = hk_user.user_id'
				),
				'filters' => array(
					'order_type' => 'hk_order.order_type = '.$order_type.''
				),
				'order' => 'hk_order.order_created DESC',
				'limit' => '{COUNTER}'
			)
		)));
?>
{/source}

Last edit: 6 years 5 months ago by derek_cts.

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
6 years 5 months ago #294296

Hi,

You need to echo the return of the display function call.
So the line:

$statisticsClass->display(array('last_orders' => array(
should be:
echo $statisticsClass->display(array('last_orders' => array(

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

  • Posts: 20
  • Thank you received: 0
6 years 5 months ago #294320

Still nothing. Neither as guest nor logged in.

Attachments:

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
6 years 5 months ago #294321

Hi,

Note that you need to initialize the variable $order_type.
So for example, you could add such line at the beginning:
$order_type='sale';
Also, maybe your tag plugin doesn't like that there are these {COUNTER}, {user_email}, etc tags inside the code.

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

  • Posts: 20
  • Thank you received: 0
6 years 5 months ago #294329

What are the allowed $order_type=''; ?

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
6 years 5 months ago #294340

Hi,

Check the order_type column in the hikashop_order table in your database and you'll see all the types.
In 95% of the cases, you'll only have the "sale" type. You can have another type for the sub-orders generated by HikaMarket for each vendor, and the affiliate system also has another type when you make pay outs to partners for their comissions.
But in your case, you want to use "sale".

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

  • Posts: 20
  • Thank you received: 0
6 years 5 months ago #294358

Ok, yeah that's what I had. Still not rendering anything when the code is put into the article.

I've checked other php code and it works.

I'm using the same codeset w/ the addition of the line:

<div id="lastOrders" style="height:500px;">
<?php
defined('_JEXEC') OR defined('_VALID_MOS') OR die( "Direct Access Is Not Allowed" );
if(!defined('DS'))
	define('DS', DIRECTORY_SEPARATOR);
				if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')) return true;
$statisticsClass = hikashop_get('class.statistics');

$order_type='sale';

echo $statisticsClass->display(array('last_orders' => array(
			'slot' => 2,
			'order' => 2,
			'published' => 1,
			'container' => 1,
			'class' => 'hkc-lg-8 hkc-sm-12',
			'type' => 'dynamic',
			'label' => JText::_('HIKA_STATS_LAST_ORDERS'),
			'vars' => array(
				'COUNTER' => 6
			),
			'prefix' => '<table style="width:100%" class="table table-striped table-hover table-bordered"><thead><tr><th>'.JText::_('ORDER_NUMBER').'</th><th>'.JText::_('ORDER_STATUS').'</th><th>'.JText::_('CUSTOMER').'</th><th>'.JText::_('DATE').'</th><th>'.JText::_('PRICE').'</th></thead><tbody>',
			'dynamic' => '<tr><td>{order_number:order_link}</td><td>{order_status:order_status}</td><td>{user_email}</td><td>{order_created:date}</td><td>{order_full_price:price}</td></tr>',
			'suffix' => '</tbody></table>',
			'format' => 'text',
			'query' => array(
				'get' => 'list',
				'select' => 'hk_order.*, hk_user.*, hk_order.order_currency_id as currency',
				'tables' => array(
					hikashop_table('order') . ' AS hk_order',
					'INNER JOIN '.hikashop_table('user').' AS hk_user ON hk_order.order_user_id = hk_user.user_id'
				),
				'filters' => array(
					'order_type' => 'hk_order.order_type = '.$order_type.''
				),
				'order' => 'hk_order.order_created DESC',
				'limit' => '{COUNTER}'
			)
		)));
?>
</div>

still not working... suggestions?

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
6 years 5 months ago #294359

Hello,

Your $order_type is not quoted.
I don't understand why you do not have a query error.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

Time to create page: 0.079 seconds
Powered by Kunena Forum