Order Dashboard - Add Custom Field as a Column

  • Posts: 15
  • Thank you received: 0
10 years 6 months ago #155470

-- url of the page with the problem -- : N/A
-- HikaShop version -- : HikaShop Essential: 2.3.0
-- Joomla version -- : 2.5.17
-- PHP version -- : 5.4
-- Browser(s) name and version -- : Chrome 34.0.1847.116
-- Error-message(debug-mod must be tuned on) -- : N/A

I have a custom field that I'd like to be visible from the orders dashboard page in the backend. The reason is that I would like to be able to use the search field to filter by this custom field and find specific orders.

How can I go about adding another column to this dashboard view? Thanks!

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

  • Posts: 15
  • Thank you received: 0
10 years 6 months ago #155481

Update. I found the correct view and I've been able to create the additional columns that I needed, but I'm not able to filter by these columns.

All of the columns that I'm looking to filter by are part of the address table if that is information that you'll need. Thanks again!

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
10 years 6 months ago #155503

Hi,

The query which loads the order data on the orders listing doesn't load the address data, so in order to have a filter on it, you would first have to change that query to add a left join to the address table in it.
Then you can have the filter add a condition to the query based on the selected value.
That cannot be done in a view, but you need to add your custom code directly in the function listing of the file administrator/components/com_hikashop/views/order/view.html.php

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

  • Posts: 15
  • Thank you received: 0
10 years 6 months ago #155607

Thank you for the information. I came across this information in a previous post ( www.hikashop.com/forum/4-how-to/53045-ad...-backend.html#120731 ) and I'm trying to alter it to fit my needs. Can you possibly tell me where I'm going wrong?

I'm attempting to left join the address table and then grab these three values to filter on: address_lastname. address_firstname, remotesupportpassword. Again, any help you can offer is greatly appreciated.

From previous forum post:
"Ok so in your case, you can edit the file: "yourSite/administrator/components/com_hikashop/views/order/view.html.php

And add the line:

$tables = ' INNER JOIN '.hikashop_table('address').' AS d LEFT JOIN; (altered by me)

Just before:

$query = ' FROM '.hikashop_table('order').' AS b LEFT JOIN '.hikashop_table('user').' AS a ON b.order_user_id=a.user_id LEFT JOIN '.hikashop_table('users',false).' AS c ON a.user_cms_id=c.id '.$tables.$filters.$order;

Oh I forgot one thing, , you need to add ",d.*" like this:

$database->setQuery('SELECT a.*,b.*,c.*,d.*'.$query,(int)$pageInfo->limit->start,(int)$pageInfo->limit->value);
in the file: "yourSite/administrator/components/com_hikashop/views/order/view.html.php and in the function listing().


Add "d.order_product_code" in the searchmap:

$searchMap = array('c.id','c.username','c.name','a.user_email','b.order_user_id','b.order_id','b.order_full_price','d.address_lastname','d.address_firstname','d.remotesupportpassword'); (altered by me)

And then you can filter by product code in the filter field on the left."

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

  • Posts: 13201
  • Thank you received: 2322
10 years 6 months ago #155670

Hi,

You can see if your query is correct or not by putting a

var_dump($query);
after:
$query = ' FROM '.hikashop_table('order').' AS b LEFT JOIN '.hikashop_table('user').' AS a ON b.order_user_id=a.user_id LEFT JOIN '.hikashop_table('users',false).' AS c ON a.user_cms_id=c.id '.$tables.$filters.$order;

That will show you the request, and then you can see if it's a valid one or not.

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

  • Posts: 15
  • Thank you received: 0
10 years 6 months ago #155772

I really don't know enough to be dangerous. Can you offer any assistance with adding this left join and the filter?

Thanks a lot!

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
10 years 6 months ago #155914

Please turn on the debug mode option of the joomla configuration and report any error that you have with the orders listing after you applied your changes and also please provide a screenshot of the different changes that you made so that we can check them and know exactly what is your situation.
Then, we can tell you what you're missing.

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

  • Posts: 15
  • Thank you received: 0
10 years 6 months ago #155938

Okay, give me some time and I'll get this to you.

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

Time to create page: 0.080 seconds
Powered by Kunena Forum