Show orders on Kunena Profile Page

  • Posts: 303
  • Thank you received: 18
  • Hikashop Business
7 years 4 months ago #256778

-- url of the page with the problem -- : www.mojooutdoors.com/index.php/profile
-- HikaShop version -- : Latest
-- Joomla version -- : 3.6.3
-- Browser(s) name and version -- : Chrome

Is there an easy way to show the same information as the user cpanel within the Kunena user profile (see attached screenshot)? I'm wanting to add it under the "ORDERS" tab. I can easily edit the Kunena to add a section where it will display, but i'm not sure how to display content outside of hikashop pages.

I know where the view file is that corresponds to the user cpanel and the customer order page. Is there any way to turn this into a joomla module to display anywhere? or better yet, can i embed this info somewhere else (i.e., the kunena profile page)?

I've noticed you guys use Kunena for this forum, so you may already have a solution (or at least i hope). Or if you guys have a better solution, i'd be open to try it out. Kunena profile page is much more aesthetically pleasing than the default joomla user page, plus, this will have everything housed under one roof.

Thank you for your time.

Attachments:

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

  • Posts: 81428
  • Thank you received: 13058
  • MODERATOR
7 years 4 months ago #256821

Hi,

There is no ready made solution.
But it should be quite easy if you know a bit your way around.
Take the CB plugin ( www.hikashop.com/support/documentation/7...mmunity-builder.html ) which role is the same but for the CB profile page, and copy the code in the getDisplayTab function, adapt the line below to kunena:
if (empty($my->id) OR $my->id != $user->user_id) return;
and paste it in the kunena file which displays the order tab.

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

  • Posts: 303
  • Thank you received: 18
  • Hikashop Business
7 years 4 months ago #256824

I understand what the line does, but i cannot for the life of me figure out what it should be for Kunena. It should pull the user ID from the kunena profile page and compare it to the customer ID, thus displaying the orders.

However, i cannot find how to adapt for kunena. Not sure what the syntax is?

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

  • Posts: 303
  • Thank you received: 18
  • Hikashop Business
7 years 4 months ago #256829

Here is what i added to my kunena file that displays will display the order tab:

<div id="kprofile-tabs">
	<dl class="tabs">
		<?php if($this->showUserPosts) : ?>
		<dt class="open" title="<?php echo JText::_('COM_KUNENA_USERPOSTS'); ?>"><?php echo JText::_('COM_KUNENA_USERPOSTS'); ?></dt>
		<dd style="display: none;">
			<?php $this->displayUserPosts(); ?>
		</dd>
		<?php endif; ?>
		<?php if ($this->showSubscriptions) :?>
		<dt class="closed" title="<?php echo JText::_('COM_KUNENA_SUBSCRIPTIONS'); ?>"><?php echo JText::_('COM_KUNENA_SUBSCRIPTIONS'); ?></dt>
		<dd style="display: none;">
			<?php $this->displayCategoriesSubscriptions(); ?>
			<?php $this->displaySubscriptions(); ?>
		</dd>
		<?php endif; ?>
		<?php if ($this->showFavorites) : ?>
		<dt class="closed" title="<?php echo JText::_('COM_KUNENA_FAVORITES'); ?>"><?php echo JText::_('COM_KUNENA_FAVORITES'); ?></dt>
		<dd style="display: none;">
			<?php $this->displayFavorites(); ?>
		</dd>
		<?php endif; ?>
		<?php if($this->showThankyou) : ?>
		<dt class="closed" title="<?php echo JText::_('COM_KUNENA_THANK_YOU'); ?>"><?php echo JText::_('COM_KUNENA_THANK_YOU'); ?></dt>
		<dd style="display: none;">
			<?php $this->displayGotThankyou(); ?>
			<?php $this->displaySaidThankyou(); ?>
		</dd>
		<?php endif; ?>
		<dt class="closed" title="<?php echo JText::_('ORDERS'); ?>"><?php echo JText::_('ORDERS'); ?></dt>
		<dd style="display: none;">
		
		<?php echo $this->profile->userid; ?>
		
		
		<?php 
		// Add Hikashop Orders to Kunena Profile
		function getDisplayTab( $tab, $user, $ui) {
		include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php');
		$my = JFactory::getUser();
		echo $this->$my;
		//only you can see your orders
		if (empty($my->id) OR $my->id != $this->profile->userid) return; //This is the line that compares the Kunena profile ID to the joomla userid?
		
		//load order info
		$database	= JFactory::getDBO();
		$searchMap = array('a.order_id','a.order_status');
		$filters = array('a.order_user_id='.hikashop_loadUser());

		$order = ' ORDER BY a.order_created DESC';
		$query = 'FROM '.hikashop_table('order').' AS a WHERE '.implode(' AND ',$filters).$order;
		$database->setQuery('SELECT a.* '.$query);
		$rows = $database->loadObjectList();

		if(empty($rows)){
			return;
		}
		$currencyHelper = hikashop_get('class.currency');
		$trans = hikashop_get('helper.translation');
		$statuses = $trans->getStatusTrans();

		ob_start();
		?>
			<table class="hikashop_orders adminlist" cellpadding="1">
				<thead>
					<tr>
						<th class="title" align="center">
							<?php echo JText::_('ORDER_NUMBER'); ?>
						</th>
						<th class="title" align="center">
							<?php echo JText::_('DATE'); ?>
						</th>
						<th class="title" align="center">
							<?php echo JText::_('ORDER_STATUS'); ?>
						</th>
						<th class="title" align="center">
							<?php echo JText::_('HIKASHOP_TOTAL'); ?>
						</th>
					</tr>
				</thead>
				<tbody>
					<?php
						$k = 0;
						for($i = 0,$a = count($rows);$i<$a;$i++){
							$row =& $rows[$i];
					?>
						<tr class="<?php echo "row$k"; ?>">
							<td align="center">
								<a href="<?php echo hikashop_completeLink('order&task=show&cid='.$row->order_id.'&cancel_url='.urlencode(base64_encode(JRoute::_('index.php?option=com_comprofiler')))); ?>">
									<?php echo hikashop_encode($row); ?>
								</a>
							</td>
							<td align="center">
								<?php echo hikashop_getDate($row->order_created,'%Y-%m-%d %H:%M');?>
							</td>
							<td align="center">
								<?php
									//get translation
									echo $statuses[$row->order_status];
								?>
							</td>
							<td align="center">
								<?php echo $currencyHelper->format($row->order_full_price,$row->order_currency_id);?>
							</td>
						</tr>
					<?php
							$k = 1-$k;
						}
					?>
				</tbody>
			</table>
		<?php

		return ob_get_clean();
		}
		?>
	
	
		</dd>

I've tried everything i could for the line you mentioned: if (empty($my->id) OR $my->id != $my->user_id) return;

I know you use this to pull the joomla user id: $this->profile->userid

However, it doesn't seem that any of the code is working? Even if i bypass that if statement, i don't see anything?

Last edit: 7 years 4 months ago by mojooutdoors-holden.

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

  • Posts: 81428
  • Thank you received: 13058
  • MODERATOR
7 years 4 months ago #256837

Hi,

Instead of:
return ob_get_clean();
You should have:
echo ob_get_clean();

Regarding the line to compare the user id from Kunena, I don't know. You should ask that on the Kunena forum. They'll be able to tell you.

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

  • Posts: 303
  • Thank you received: 18
  • Hikashop Business
7 years 4 months ago #256856

I finally managed to get it working with some tweaking of the function.



For anyone interested, you can the first bit of the plugin mentioned to:
<?php
		// Add Hikashop Orders to Kunena Profile
		function getDisplayTab($user) {
		include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php');
		$my = JFactory::getUser();
		//only you can see your orders
		if (empty($my->id) OR $my->id != $user) return;

Then when displaying the content, you need to pass the Kunena user-id to the function via:
$user_id = $this->profile->userid;
		echo getDisplayTab($user_id);


One more question: When i click the order numbers, it takes me to a page outside of kunena.



Is there any easy way to make this a popup or stay within kunena?

Attachments:

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

  • Posts: 81428
  • Thank you received: 13058
  • MODERATOR
7 years 4 months ago #256874

Hi,

You can use an extension like that:
extensions.joomla.org/extension/modals
in order to transform the link:

<a href="<?php echo hikashop_completeLink('order&task=show&cid='.$row->order_id.'&cancel_url='.urlencode(base64_encode(JRoute::_('index.php?option=com_comprofiler')))); ?>">
into a popup link. Just add the parameter &tmpl=component in order to transform the link into a template-less link so that it displays better in the popup.

The following user(s) said Thank You: kyratn

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

  • Posts: 303
  • Thank you received: 18
  • Hikashop Business
7 years 4 months ago #256987

Works perfectly! Thanks for all of your help!

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

Time to create page: 0.082 seconds
Powered by Kunena Forum