News:

Support the VirtueMart project and become a member

Main Menu

Virtuemart 2.0.12f order number plugin

Started by knutmw, October 25, 2012, 14:26:21 PM

Previous topic - Next topic

knutmw

Hi
I know that this is mention in several other topics, but can't fint a solution on the problem.
VM 2 order number make no sense to customers at all.

It's great that you can look at the order without login to the system, by just clicking email link.
But the order number is a referens point for the customer when contacting me as a store owner.
And it's hopeless to have order number like this. "c2b0575"

I have been reading about a plugin to solve this? but can't seem to find one anywhere.

I can buy something to get this working.
But need a safe way to make order number like this "c2b0575" into "00001" and "00002" and so on.
I have used the VM 1 to VM 2 migration tool, and have sucsessfully transferd orders number from old to new lik it was in VM 1 and thats good.

Hope on positiv feedback, and i am sure that I am not the only one out here wanting this to get this fixed, or mayed possibel to do.
I know it working as i was ment to be. But an option had been great here.

It in fact so importent to me, that if i can't have this i consider looking for other shopcart software. But that will cost a tonn of work, and I like Virtuemart, but hate the order numbers it have today.

Looking forward to here from someone. :)




WebStuff

Not much help I'm afraid. But I think it should at least be an option in Shop->Configuration.
Some thing like "Add Prefix to Order Number" with options for:
1/. fixed text or 2/. the date using format strings(like YYYY-MM-DD) or 3/. a random number.

As far as I'm aware there is no legal requirement in any countries to have order numbers so mashed up.

i think the only way to do it in the mean time is a code hack on core files.

Sorry I can't be more help.

franayala

Try to investigate this:

in administrator/components/com_virtuemart/models/orders.php




//Comment for orders
//$data = substr( md5( session_id().(string)time().(string)$uid ) ,0 ,$length ).'0'.$count;
//Replace with
$data = 'P-' . (string)date("Y") . '-' .$count;

//comment for invoices
//$data['invoice_number'] = str_replace('-', '', substr($date,2,8)).substr(md5($orderDetails['order_number'].$orderDetails['order_status']),0,3).'0'.$count;
//Replace with
$data['invoice_number'] = 'F-' . (string)date("Y") . '-' .$count;
www.cuidadicos.es - Natural suplements and beauty

WebStuff

Thanks  franayala
I was nearly there.

There are a couple of places.
In administrator/components/com_virtuemart/models/orders.php

public function generateOrderNumber($uid = 0,$length=10, $virtuemart_vendor_id=1)
{

$db = JFactory::getDBO();

$q = 'SELECT COUNT(1) FROM #__virtuemart_orders WHERE `virtuemart_vendor_id`="'.$virtuemart_vendor_id.'"';
$db->setQuery($q);

//We can use that here, because the order_number is free to set, the invoice_number must often follow special rules
$count = $db->loadResult();
$count = $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);
// ALTERED TO JUST COUNT IF YOU WANT FOR OLD STYLE ORDER NUMBERS
$data = $count;
// END ALTERED CODE
// ORIGINAL LINE BELOW
//$data = substr( md5( session_id().(string)time().(string)$uid ) ,0 ,$length ).'0'.$count;

return $data;
}

And in the function _createOrder in that file change to:

if(empty($_orderData->order_pass)){
// ALTERED FOR OLD STYLE ORDER NUMBERS
$_orderData->order_pass = 'p_'.$_orderData->order_number;
// END ALTERED CODE
// ORIGINAL LINE BELOW
//$_orderData->order_pass = 'p_'.substr( md5((string)time().rand(1,1000).$_orderData->order_number ), 0, 5);
}


Also in administrator/components/com_virtuemart/tables/orders.php :

function check(){

if(empty($this->order_number)){
if(!class_exists('VirtueMartModelOrders')) require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'orders.php');
$this->order_number = VirtueMartModelOrders::generateOrderNumber((string)time());
}

if(empty($this->order_pass)){
// ALTERED BY DAVE FOR NORMAL ORDER NUMBERS
$this->order_pass = 'p_'.$this->order_number;
// END ALTERED CODE
// ORIGINAL LINE BELOW
//$this->order_pass = 'p_'.substr( md5((string)time().$this->order_number ), 0, 5);
}

return parent::check();
}


Hope this helps.

reinhold

#4
I have now created such a plugin, which allows the shop owner to change the order number, order password and invoice number at will:
http://open-tools.net/virtuemart-2-extensions/40-vm2-ordernumber.html

The format is given as a text string, where [...] is understood as a variable and replaced by its value (e.g. [year] by the current year).

The running counter is indicated by #. The counter can be configured to be global (e.g. not reset each year/month/..) or a separate counter for each year/month/...
If you only want the order number as a running count, the format is simply '#' (without the quotes). If you want to prefix the order/invoice numbers by the year or year+month then the format it simply '[year]-#' or '[year2][month]#'... If you want the invoice number to be the same as the order number (this might not fulfill some legal requirements about invoices having successive numbers!), you can simply use '[orderNumber]'.
There are many more possibilities in the plugin!

I hope you like the plugin and it does what you need.