Page 1 of 1

orders.php column adding

Posted: Sat Jul 30, 2022 1:32 pm
by Piernas
I'm trying to add a column in orders.php using the injectColumns hook with no success so I may be misunderstanding how this works.

I'm getting this:
Warning: Array to string conversion in includes\system\versioned\1.0.8.1\hooks.php on line 151
What am I doing wrong?

Re: orders.php column adding

Posted: Mon Aug 29, 2022 8:43 am
by dmenhinick
Thanks for posting your solution. I have copied the exact text in your code sample and saved in includes/hooks/admin/siteWide/order_extend.php. I know it's read because without <?php at the top it throws an error, however I don't see the new column in the orders table?

Also is injectColumns a hook in the core?

Re: orders.php column adding

Posted: Mon Aug 29, 2022 9:21 am
by dmenhinick
So I added my own hook line just under the table definition line to admin/includes/actions/orders/views/default.php and now the code works as expected and is exactly what I need, but my question now is how do I do this without editing core files?

Re: orders.php column adding

Posted: Mon Aug 29, 2022 10:43 am
by Kofod95
I think the hook-call is in the paginated table class, but don't have time to look right now

//Daniel

Re: orders.php column adding

Posted: Mon Aug 29, 2022 2:47 pm
by dmenhinick
I have searched the entire CE Phoenix v1.0.8.17 base for injectColumns and don't find it?

Re: orders.php column adding

Posted: Sun Sep 11, 2022 8:15 pm
by Omar_one
dmenhinick wrote: Mon Aug 29, 2022 9:21 am So I added my own hook line just under the table definition line to admin/includes/actions/orders/views/default.php and now the code works as expected and is exactly what I need, but my question now is how do I do this without editing core files?
you don't need to edit the core , try this (save it includes/hooks/admin/orders/xxxx.php) change xxxx as you want

Code: Select all

class hook_admin_orders_xxxx {
	
   public function listen_constructPaginator($paginator) {
    $GLOBALS['table_definition']['columns'][] = [
      'name' => "Testing",
      'class' => 'text-right',
      'function' => function ($row) {
        return $row['customers_country'];
      },
    ];
  }  
 }
test on 1.0.8.17

Re: orders.php column adding

Posted: Tue Oct 04, 2022 2:03 pm
by dmenhinick
Thanks so much, I think I need to go over hooks again. Apparently I still don't understand exactly what they are.