Jump to content

Display addresses and product names columns in the Back Office/Orders Tab


Recommended Posts

I added a row (city) to this code, and appeard a new "city" column.

The code (AdminOrders.php):

foreach ($states AS $state)
           $statesArray[$state['id_order_state']] = $state['name'];
        $this->fieldsDisplay = array(
       'id_order' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
       'new' => array('title' => $this->l('New'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'filter_key' => 'new', 'tmpTableFilter' => true, 'icon' => array(0 => 'blank.gif', 1 => 'news-new.gif'), 'orderby' => false),
       'customer' => array('title' => $this->l('Customer'), 'widthColumn' => 160, 'width' => 140, 'filter_key' => 'customer', 'tmpTableFilter' => true),

       'city' => array('title' => $this->l('city'), 'widthColumn' => 80, 'width' => 60, 'filter_key' => 'city', 'tmpTableFilter' => true),

       'total_paid' => array('title' => $this->l('Total'), 'width' => 70, 'align' => 'right', 'prefix' => '', 'suffix' => '', 'price' => true, 'currency' => true),
       'payment' => array('title' => $this->l('Payment'), 'width' => 100),
       'osname' => array('title' => $this->l('Status'), 'widthColumn' => 250, 'type' => 'select', 'select' => $statesArray, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int', 'width' => 200),
       'date_add' => array('title' => $this->l('Date'), 'width' => 90, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add'),
       'id_pdf' => array('title' => $this->l('PDF'), 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false));
       parent::__construct();



How can I display the customer's address (city) in this column?

Thanks!
Smicikli

Link to comment
Share on other sites

  • 1 month later...

you have to modify select in $this->_select variable to contain also new column or you could write a callback function to return the address.

I used the latter approach when I needed to add carrier icon to orders list in AdminOrders screen. This is what I did(you can use it as inspiration):

First I added the column carrier_pdf, that calls function PrintCarrierIcons

       foreach ($states AS $state)
           $statesArray[$state['id_order_state']] = $state['name'];
        $this->fieldsDisplay = array(
       'id_order' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
       'new' => array('title' => $this->l('New'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'filter_key' => 'new', 'tmpTableFilter' => true, 'icon' => array(0 => 'blank.gif', 1 => 'news-new.gif'), 'orderby' => false),
       'customer' => array('title' => $this->l('Customer'), 'widthColumn' => 160, 'width' => 140, 'filter_key' => 'customer', 'tmpTableFilter' => true),
       'total_paid' => array('title' => $this->l('Total'), 'width' => 70, 'align' => 'right', 'prefix' => '', 'suffix' => '', 'price' => true, 'currency' => true),
       'payment' => array('title' => $this->l('Payment'), 'width' => 100),
       'osname' => array('title' => $this->l('Status'), 'widthColumn' => 250, 'type' => 'select', 'select' => $statesArray, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int', 'width' => 200),
       'carrier_pdf' => array('title' => $this->l('Dop'), 'width' => 20, 'callback' => 'printCarrierIcons', 'orderby' => false, 'search' => false),
   'date_add' => array('title' => $this->l('Date'), 'width' => 80, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add'),
       'id_pdf' => array('title' => $this->l('PDF'), 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false));
       parent::__construct();
   }



Then I modified Orders class (Orders.php) - I added new PrintCarrierIcons function that display the image

   static public function printCarrierIcons($id_order, $tr)
   {
       $order = new Order($id_order);
       $orderState = OrderHistory::getLastOrderState($id_order);
       if (!Validate::isLoadedObject($orderState) OR !Validate::isLoadedObject($order))
           die(Tools::displayError('Invalid objects!'));
       echo '';
       if ($order->id_carrier==21)
     echo '';
       else if ($order->id_carrier==24)
     echo '';
   else if ($order->id_carrier==25)
     echo '';
   else
       echo ' ';
       echo '';
       echo '';
   }

Link to comment
Share on other sites

  • 5 weeks later...
×
×
  • Create New...