Virtuemart Change Order number
To change the order number generation do as follows:
-
Go to administrator/components/com_virtuemart/classes/ps_checkout.php Find the following function - get_order_number() and change
<?php ... function get_order_number() { global $auth; /* Generated a unique order number */ $str = session_id(); $str .= (string)time(); $date = date('d.m.Y'); $db =& JFactory::getDBO(); $query = " SELECT order_id FROM #__vm_orders "; $db->setQuery($query); $column= $db->loadResultArray(); $anzahl = count($column) + 1; $order_number = "Nike ".$anzahl." - ".$date ; return substr($order_number, 0, 32); }
-
Go to administrator/components/com_virtuemart/classes/ps_order.php at line 308 change
to<?php ... $q = "SELECT first_name,last_name,user_email,order_status_name FROM #__{vm}_order_user_info,#__{vm}_orders,#__{vm}_order_status ";
<?php ... $q = "SELECT first_name,last_name,order_number,user_email,order_status_name FROM #__{vm}_order_user_info,#__{vm}_orders,#__{vm}_order_status ";
at line 340 and 343, change
<?php
...
$d["order_id"]
<?php
...
$d["order_number"]
Now, in the account maintenance panel, displaying the order_number instead of the id is something I’ve not been able get to correctly work out, so if someone could get that working, this would be complete.
- In the same file, (administrator/components/com_virtuemart/classes/ps_order.php) at line 615 or find the code.
to
<?php ... $tmp_cell .= "<br /><strong>".$VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_NUMBER').":</strong> " . sprintf("%08d", $db->f("order_id"));
<?php ... $tmp_cell .= "<br /><strong>".$VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_NUMBER').":</strong> " . sprintf($db->f("order_number"));
and at line 559 change
<?php
...
$listfields = 'cdate,order_total,order_status,order_id,order_number,order_currency';
<?php
...
$listfields = 'cdate,order_total,order_status,order_id,order_currency';
-
Now, go to administrator/components/com_virtuemart/html/account.order_details.php and change the code.
to<?php ... $mainframe->setPageTitle( $VM_LANG->_('PHPSHOP_ACC_ORDER_INFO').' : '.$VM_LANG->_('PHPSHOP_ORDER_LIST_ID').' '.$db->f('order_id'));
$mainframe->setPageTitle( $VM_LANG->_('PHPSHOP_ACC_ORDER_INFO').' : '.$VM_LANG->_('PHPSHOP_ORDER_LIST_ID').' '.$db->f('order_number'));
-
finally, go to components/com_virtuemart/themes/default/templates/pages/account.order_details.tpl.php
to<td><?php printf("%08d", $db->f("order_id")); ?></td>
<td><?php printf($db->f("order_number")); ?></td>
Here will be the link