orders.php column adding

Ask the community for help and support.
Post Reply
Piernas
Posts: 96
Joined: Thu Mar 11, 2021 2:16 am
Has thanked: 2 times
Been thanked: 4 times

orders.php column adding

Post 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?
dmenhinick
Posts: 10
Joined: Wed Aug 24, 2022 7:22 am
Has thanked: 5 times

Re: orders.php column adding

Post 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?
dmenhinick
Posts: 10
Joined: Wed Aug 24, 2022 7:22 am
Has thanked: 5 times

Re: orders.php column adding

Post 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?
User avatar
Kofod95
VIP Member
VIP Member
Posts: 605
Joined: Sat Feb 06, 2021 7:38 pm
Has thanked: 80 times
Been thanked: 141 times

Re: orders.php column adding

Post by Kofod95 »

I think the hook-call is in the paginated table class, but don't have time to look right now

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
dmenhinick
Posts: 10
Joined: Wed Aug 24, 2022 7:22 am
Has thanked: 5 times

Re: orders.php column adding

Post by dmenhinick »

I have searched the entire CE Phoenix v1.0.8.17 base for injectColumns and don't find it?
Omar_one
VIP Member
VIP Member
Posts: 481
Joined: Fri Oct 25, 2019 5:06 pm
Has thanked: 48 times
Been thanked: 27 times

Re: orders.php column adding

Post 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
dmenhinick
Posts: 10
Joined: Wed Aug 24, 2022 7:22 am
Has thanked: 5 times

Re: orders.php column adding

Post by dmenhinick »

Thanks so much, I think I need to go over hooks again. Apparently I still don't understand exactly what they are.
Post Reply