News:

Looking for documentation? Take a look on our wiki

Main Menu

Sequential order and invoice numbers

Started by JanZet, April 27, 2013, 19:25:15 PM

Previous topic - Next topic

JanZet

To start the ordernumber from 20130001 and create sequential order numbers I have changed these files:

administrator\components\com_virtuemart\helpers\config.php
line 48: defined('VM_ORDER_OFFSET') or define('VM_ORDER_OFFSET',20130001);

administrator\components\com_virtuemart\models\orders.php
line 1143       //We can use that here, because the order_number is free to set, the invoice_number must often follow special rules
      $count = $db->loadResult();
      $data = $count + (int)VM_ORDER_OFFSET;
//       vmdebug('my db creating ordernumber VM_ORDER_OFFSET '.VM_ORDER_OFFSET.' $count '.$count, $this->_db);
//       $variable_fixed=sprintf("%06s",$num_rows);
//      $data = substr( md5( session_id().(string)time().(string)$uid )
//      ,0
//      ,$length
//      ).'0'.$count;

      return $data;
   }
line 1203
               if(empty($data['invoice_number'])) {
                  //$variable_fixed=sprintf("%05s",$num_rows);
   //               $date = date("Y-m-d");
   //                $date = JFactory::getDate()->toMySQL();
   //               $data['invoice_number'] = str_replace('-', '', //substr($date,2,8)).substr(md5($orderDetails['order_number'].$orderDetails['order_status']),0,3).'0'.$count;
                  $data['invoice_number'] = $orderDetails['order_number'];

In this case the first order and invoicenumber will have number 20130001 and the next 20130002 and so on.
I hope you can use it

K&K media production

This is a core hack and not recommended. You will lost the changes if you update Virtuemart.

A better way is to use this plugin

http://extensions.virtuemart.net/vm-orders/order-number-plugin-detail

AH

Nice hack

Regarding the plugin, this will suit many users of VM and not suit others.

Some will not want to depend on third party plugins.

Regards
A

Joomla 3.10.11
php 8.0

ofoufou

hi could you please confirm that this is still working because on line  1143 on orders.php i have 

$_orderItems->product_quantity = $_prod->quantity;
         //We can use that here, because the order_number is free to set, the invoice_number must often follow special rules
      $count = $db->loadResult();
      $data = $count + (int)VM_ORDER_OFFSET;
//       vmdebug('my db creating ordernumber VM_ORDER_OFFSET '.VM_ORDER_OFFSET.' $count '.$count, $this->_db);
//       $variable_fixed=sprintf("%06s",$num_rows);
//      $data = substr( md5( session_id().(string)time().(string)$uid )
//      ,0
//      ,$length
//      ).'0'.$count;

and on line 1203

   
         foreach($calculation_kinds as $calculation_kind) {

            if(!isset($_cart->pricesUnformatted[$key][$calculation_kind])) continue;
            $productRules = $_cart->pricesUnformatted[$key][$calculation_kind];

schould i add the lines somewhere else ?

Thank you in advance for your help.

sytc

This still works..

except I had to make the second part of the code for orders.php


if(empty($data['invoice_number'])) {
//$variable_fixed=sprintf("%05s",$num_rows);
// $date = date("Y-m-d");
// $date = JFactory::getDate()->toMySQL();
// $data['invoice_number'] = str_replace('-', '', substr($date,2,8)).substr(md5($orderDetails['order_number'].$orderDetails['order_status']),0,3).'0'.$count;
$data['invoice_number'] = str_replace('-', '', substr($date,2,8)).$orderDetails['order_number'];


and its at line 1449

first part is at line 1389