Tuesday, November 16, 2010

[Virtuemart] Customize Order List - adding extra column

In this post, I am going explain on how to add an extra column in Virtuemart Administrator Order List page.

(Note that, in this example, I'm going to add a new address_1 column).

Note: Please refer to my previous post on "adding search keywords" for the SQL query code for the other fields that you want.

Getting Started.

In /administrator/components/com_virtuemart/html/order.order_list.php

locate this section, around line 27. Then add "address_1" into the line, as below.

//$list .= "first_name, last_name FROM #__{vm}_orders, #__{vm}_order_user_info WHERE ";

// This is the modified line.

$list .= "first_name, last_name, address_1 FROM #__{vm}_orders, #__{vm}_order_user_info WHERE ";


After that, locate this section, as usual and note that "Address_1" is already the added column.

$columns = Array( "#" => "width=\"20\"",

"<input type=\"checkbox\" name=\"toggle\" value=\"\" onclick=\"checkAll(".$checklimit.")\" />" => "width=\"20\"",

$VM_LANG->_('PHPSHOP_ORDER_LIST_ID') => '',

$VM_LANG->_('PHPSHOP_ORDER_PRINT_NAME') => '',

// This is you "address_1" column header,

'Address_1' => '',

$VM_LANG->_('PHPSHOP_ORDER_LIST_PRINT_LABEL') => '',

$VM_LANG->_('PHPSHOP_ORDER_LIST_TRACK') => '',

$VM_LANG->_('PHPSHOP_ORDER_LIST_VOID_LABEL') => '',

$VM_LANG->_('PHPSHOP_CHECK_OUT_THANK_YOU_PRINT_VIEW') => '',

$VM_LANG->_('PHPSHOP_ORDER_LIST_CDATE') => '',

$VM_LANG->_('PHPSHOP_ORDER_LIST_MDATE') => '',

$VM_LANG->_('PHPSHOP_ORDER_LIST_STATUS') => '',

$VM_LANG->_('PHPSHOP_UPDATE') => '',

$VM_LANG->_('PHPSHOP_ORDER_LIST_TOTAL') => '',

$VM_LANG->_('E_REMOVE') => "width=\"5%\""

);

$listObj->writeTableHeader( $columns );


As you can see, those are the column headers for the table, and the last line is the function to print out all the column headers.

Then, you will need to locate this section of code, and add $db->f('address_1'); as below:

$tmp_cell = $db->f('first_name').' '.$db->f('last_name');

if( $perm->check('admin') && defined('_VM_IS_BACKEND')) {

$url = $_SERVER['PHP_SELF']."?page=admin.user_form&amp;user_id=". $db->f("user_id");

$tmp_cell = '<a href="'.$sess->url( $url ).'">'.$tmp_cell.'</a>';

}


$listObj->addCell( $tmp_cell );

// This will print "address_1" column, which is placed afer the "Name" column

$tmp_cell = $db->f('address_1');

$listObj->addCell( $tmp_cell );


Note: The ordering of the the print cell function (i.e. the $listObj->addCell( $tmp_cell ); ) is important, as you wouldn't want to jumble up the different fields.Thats all.

Hope this help :)

You can find the original post here : http://blog.gbinghan.com/2010/10/virtuemart-customize-order-list-adding.html

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.