Skip to main content

[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 :)

Comments

  1. oh my god u are amazing
    thnx
    can you add the products in this list???

    ReplyDelete
  2. @mezo You can add these line to include the order_item_name/vendor_id in the search:

    $list .= "vendor_id, #__{vm}_order_item.order_item_name, ";

    $list .= "JOIN #__{vm}_order_item ON #__{vm}_orders.order_id=#__{vm}_order_item.order_id WHERE ";


    and locate similar lines to the following, and add these (keyword filter) in between the lines:

    $q .= "OR order_item_name LIKE '%$keyword%' ";
    $q .= "OR order_item_name LIKE '%$keyword%' ";

    Hope it helps.

    Tell me if you find the above explanation is not clear.

    ReplyDelete
  3. can u give me more details please
    thank you for your help

    ReplyDelete
  4. This imformation is a great help. Try to keep your imformation. I and other people need to understand about it. Thank you !

    ReplyDelete
  5. $list  = "SELECT #__{vm}_orders.order_id,order_status, #__{vm}_orders.cdate,#__{vm}_orders.mdate,order_total,order_currency,#__{vm}_orders.user_id, ";
    $list .= "first_name, last_name, vendor_name FROM #__{vm}_vendor, #__{vm}_orders, #__{vm}_order_user_info WHERE ";
    $count = "SELECT count(*) as num_rows FROM #__{vm}_orders, #__{vm}_order_user_info WHERE ";

    BAD TABLE!!!! ALL vendors insert? help my? please
    roooma@ipnet.kiev.ua

    ReplyDelete
  6. I like this direction. My question is how can this be done to show a attribute. For example I have a greeting card website where a customer can choose a writing style for their message to be hand written in the card for them and I would like this style to carry over and be a column in the order list and show up in each order details. Hope that makes sense.

    Kindest Regards,
    Jeremy

    ReplyDelete
  7. Bing Han, Can you help me with the below post? Thank you.

    ReplyDelete
  8. Hey, so sorry for the late reply. Was busy with project deadlines these few days.

    I guess the above guide more or less points you to the direction of adding new fields. So now you just need to display it in the order details page?

    I'll see if I can look into it (hopefully come up with a guide) next week. On a trip this weekend.

    ReplyDelete
  9. Bing,


    Thank you for your help. I just want to display attribute in the Order List that way as my handwriters are going in to check the orders they can see which one is theirs without having to click into the order to see the attribute selection.


    I guess just let me know. my email is jeremy@revolutionwebstudios.com


    Thank you,
    Jeremy

    ReplyDelete
  10. Hi Bing Han Goh,


    My name is anoop, I am customizing the backend of virtuemart 2.06. In the order list we can see Filter Name: Go Reset Order Status: these two fields ,
    I need to add an additional fields to select the order by date . I searched all the files , but didnt found, displayDefaultViewSearch function in the vmview.php page. which page i have to edit if i have to add another filter to it . please reply . anoop@wsdtech.com

    ReplyDelete
  11. I love that you outlined the codes for adding extra column in Virtuemart Customize Order list in such a clear, concise way.

    ReplyDelete
  12. Hello BIng Han Goh,

    tnanks for the information.

    I'd like to add an extra column in Virtuemart Administrator Order List page with the product image. How can I do it?

    Thanks for the help.

    I have already the column, but I can't figure out how to show the image.

    ReplyDelete

Post a Comment

Popular posts from this blog

225019099301.apps.googleusercontent.com

Recent activity on my Gmail just revealed that there's this app "Authorized Application (225019099301.apps.googleusercontent.com)" from IP address 54.235.159.144 assessing my Gmail.

The IP address is from a Amazon server ec2-54-235-159-144.compute-1.amazonaws.com. (IP Lookup).

And blacklist check (http://whatismyipaddress.com/blacklist-check) shows that the IP is clean too.

Clicking on the "Manage Account Access" didn't give any information on the application "225019099301.apps.googleusercontent.com".


After Googling, it appears that the app is Mailbox (source: http://productforums.google.com/forum/#!topic/gmail/9LVW_etXyTE)

To make things easy, Google should show the applications with their ID.


Backup MySQL to Azure Storage in 30 Seconds

Step 1. Disable password prompt for "mysqldump command"mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: NO) when trying to connect 1. Run "vi ~/.my.cnf"
2. Add the following lines

[mysqldump]user=mysqluser password=secret
3. For Bitnami, you'll need to append the following line in "/opt/bitnami/mysql/my.cnf"

!include ~/.my.cnf
4. Try running to see if the command works.
mysqldump --all-databases > /home/bitnami/backups/db-backup.sql



Step 2(a). Install Azure-CLI Prerequisites: Installing npm.sudo apt-get update sudo apt-get install nodejs sudo apt-get install npm Note: If you facing issue while installing nodejs/npm on Ubuntu 12.04, you can refer to his article for alternative way to install https://rtcamp.com/tutorials/nodejs/node-js-npm-install-ubuntu/, or this http://stackoverflow.com/questions/16302436/install-nodejs-on-ubuntu-12-10#comment32247107_16303380

Install Azure CLI.npm install azure-cl…

Generate GoDaddy SSL Certificate (.crt) for Azure Websites (.pfx)

Step 1: Getting GoDaddy SSL cert.
Let's say you have a domain name of my_domain.com. You'll first need to generate the the .csr file for GoDaddy with the following command:

openssl req -new -newkey rsa:2048 -nodes -keyout my_domain.com.key -out my_domain.com.csr


This gives you 2 files:
my_domain.com.key - This is the private key
my_domain.com.csr - This is the Certificate Signing Request


Copy the content of my_domain.com.csr file to the SSL signing authority (GoDaddy).



Once approved, GoDaddy give you back a .zip file with the following 2 files:

18f1c77f369c0b59.crt - This is your cert
gd_bundle-g2-g1.crt - This is the GoDaddy Certificate Chain


Step 2: Convert a CERT/PEM certificate to a PFX certificate
openssl pkcs12 -export -out my_domain.com.pfx -inkey my_domain.com.key -in 18f1c77f369c0b59.crt


Step 3: Certificate to Upload to Azure.


Step 4: Assign SSL Bindings.




Step 5: Done!


References:

http://azure.microsoft.com/en-us/documentation/articles/web-sites-configure-ssl-certificate…