How to show order history in frontend?

  • Posts: 174
  • Thank you received: 2
  • Hikashop Business
12 years 7 months ago #44184

now i'm only can show list of orders and here user can see last updated order status. But what if i want to show for user all his order history:
When order status changed, what was the name of order status and even what was the Modification reason for that.

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

  • Posts: 13201
  • Thank you received: 2322
12 years 7 months ago #44347

Hi arnask,


You can display these different informations, you have to edit:
yourSite\components\com_hikashop\views\order\view.html.php > function listing().

Add:

foreach($rows as $k => $hist){
			$database->setQuery('SELECT * FROM '.hikashop_table('history').' WHERE history_id IN(SELECT max(history_id) FROM '.hikashop_table('history').' WHERE `history_order_id` = '.$rows[$k]->order_id.' AND history_type = "modification" )');
			$rows[$k]->history = $database->loadObjectList();
		}

Before:
$this->assignRef('rows',$rows);

And in :
yourSite\components\com_hikashop\views\order\tmpl\listing.php

Add:
<?php
echo '<br/>'.hikashop_getDate($row->order_modified,'%Y-%m-%d %H:%M').' / ';
echo $row->history[0]->history_new_status.' / ';
echo $row->history[0]->history_reason; ?>

In the listing table, after the line:
<?php echo $row->order_number; ?>

Last edit: 12 years 7 months ago by nicolas.

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

  • Posts: 174
  • Thank you received: 2
  • Hikashop Business
12 years 7 months ago #44408

Parse error: syntax error, unexpected T_VARIABLE in .../components/com_hikashop/views/order/tmpl/listing.php on line 123

where exactly is "In the listing table, between <tr><td> tags for each elements" can you provide line numbers?

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

  • Posts: 82683
  • Thank you received: 13337
  • MODERATOR
12 years 7 months ago #44410

I've fixed the code in the previous message, please try with that new code.

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

  • Posts: 174
  • Thank you received: 2
  • Hikashop Business
12 years 7 months ago #44418

no good:

Attachments:
Last edit: 12 years 7 months ago by arnask.

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

  • Posts: 82683
  • Thank you received: 13337
  • MODERATOR
12 years 7 months ago #44420

Make sure that you also add the first modification in your view.html.php file

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

  • Posts: 174
  • Thank you received: 2
  • Hikashop Business
12 years 7 months ago #44426

yes i've done that. Now it loks like:

$this->assignRef('params',$params);
		foreach($rows as $k => $hist){
			$database->setQuery('SELECT * FROM '.hikashop_table('history').' WHERE history_id IN(SELECT max(history_id) FROM '.hikashop_table('history').' WHERE `history_order_id` = '.$rows[$k]->order_id.' AND history_type = "modification" )');
			$rows[$k]->history = $database->loadObjectList();
		}
		$this->assignRef('rows',$rows);


Attachments:

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

  • Posts: 82683
  • Thank you received: 13337
  • MODERATOR
12 years 7 months ago #44436

So that means that there was no reason given in the last modification of the order.

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

  • Posts: 174
  • Thank you received: 2
  • Hikashop Business
12 years 7 months ago #44442

yes, but i still can not see all the history of order. Only the last change.
What if there was 5 order changes with different reasons in different time. I can not see that.

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

  • Posts: 82683
  • Thank you received: 13337
  • MODERATOR
12 years 7 months ago #44445

You would have to use that code then:

<?php
foreach($row->history as $hist){
echo '<br/>'.hikashop_getDate($row->order_modified,'%Y-%m-%d %H:%M').' / ';
echo $hist->history_new_status.' / ';
echo $hist->history_reason; 
} 
?>

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

  • Posts: 174
  • Thank you received: 2
  • Hikashop Business
12 years 7 months ago #44446

still the last one. No history.

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

  • Posts: 82683
  • Thank you received: 13337
  • MODERATOR
12 years 7 months ago #44447

Change also the line:
$database->setQuery('SELECT * FROM '.hikashop_table('history').' WHERE history_id IN(SELECT max(history_id) FROM '.hikashop_table('history').' WHERE `history_order_id` = '.$rows[$k]->order_id.' AND history_type = "modification" )');

to:
$database->setQuery('SELECT * FROM '.hikashop_table('history').' WHERE history_id IN(SELECT history_id FROM '.hikashop_table('history').' WHERE `history_order_id` = '.$rows[$k]->order_id.' AND history_type = "modification" )');

in the other file (the view.html.php)

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

  • Posts: 174
  • Thank you received: 2
  • Hikashop Business
12 years 7 months ago #44474

now it ok, onnly we need to handle dates, because everything is in the same last modification date.
And of course we need to handle languages of order statuses to disply correctly with Falang.

But already thank you nicolas!

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

  • Posts: 13201
  • Thank you received: 2322
12 years 7 months ago #44484

Hi arnask,

For the dates, you can use :

$hist->history_created;

Last edit: 12 years 7 months ago by Xavier.

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

  • Posts: 174
  • Thank you received: 2
  • Hikashop Business
12 years 7 months ago #44678

still it shows the last modification date for all modifications.
Date is in some numbers format.
Order statuses are not in correct language.

now code in listing.php looks:

<?php
foreach($row->history as $hist){
echo '<br/>'.hikashop_getDate($row->order_modified,'%Y-%m-%d %H:%M').' / ';
echo $hist->history_new_status.' / ';
echo $hist->history_reason;
echo $hist->history_created;  
} 
?>

and in website it looks like:

Attachments:

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

  • Posts: 82683
  • Thank you received: 13337
  • MODERATOR
12 years 7 months ago #44860

Do like that instead:

<?php
foreach($row->history as $hist){
echo '<br/>'.hikashop_getDate($hist->history_created,'%Y-%m-%d %H:%M').' / ';
echo $hist->history_new_status.' / ';
echo $hist->history_reason;
} 
?>

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

  • Posts: 174
  • Thank you received: 2
  • Hikashop Business
12 years 7 months ago #45008

Thanks, it works now. But there is still language issue. How to make "history_new_status" display correct language?

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

  • Posts: 82683
  • Thank you received: 13337
  • MODERATOR
12 years 7 months ago #45167

You can replace:
$hist->history_new_status
by:
$this->order_statuses->trans($hist->history_new_status)

in the previous code.

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

  • Posts: 174
  • Thank you received: 2
  • Hikashop Business
12 years 2 months ago #62200

after updating hikashop, everything has gone, and now i need to do it all again. Is there a chance that it will be implemented in future hikashop?
I think this feature is very useful, and VM is a big competitor in this field.
Is there a possibility to attache file in frontend near all users orders? I need to give a special reports for my customers about theirs orders.
For example when i'm changing order status, i'm putting a modification reason and need to attache a file to it. So that this file could be in email and in frontend "My orders" section.

Last edit: 12 years 2 months ago by arnask.

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

  • Posts: 82683
  • Thank you received: 13337
  • MODERATOR
12 years 2 months ago #62262

If you do your modifications via the menu Display->Views you won't loose them when you update.

If you create a custom field of the table "order" and of the type "file" which is unpublished for the front end, you can have such upload possibility. The file will be in the email and in the order details page automatically.

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

Time to create page: 0.116 seconds
Powered by Kunena Forum