VM2 Object of class JDate could not be converted to string in orders.php Ln 997

Started by kaiman, March 01, 2012, 11:11:47 AM

Previous topic - Next topic

kaiman

Hi,

i have got a problem w/ VM202.
When a shopper tries to checkout his order, he will get: Catchable fatal error: Object of class JDate could not be converted to string in /administrator/components/com_virtuemart/models/orders.php on line 997

What is going wrong?
No order or mail is generated.

regards

kaiman

idbrokers


ChrisTrembath

I also have this problem,
Im using an offline credit card plugin baught from VM extensions and its giving the same error when click confirm order.

I tried switching the file orders.php to the one from virtuemart 2.00 and the checkout works but still does not send confirmation email

Frantishik

update 997 string in /administrator/components/com_virtuemart/models/orders.php:

$data['invoice_number'] = str_replace('-', '', substr(JFactory::getDate(),2,8)).substr(md5($orderDetails['order_number'].$orderDetails['order_status']),0,3).'0'.$count;
on
$data['invoice_number'] = str_replace('-', '', substr(date("H:i:s Y-m-d"),2,8)).substr(md5($orderDetails['order_number'].$orderDetails['order_status']),0,3).'0'.$count;
:)

Milbo

Quote from: Frantishik on March 08, 2012, 15:53:32 PM
update 997 string in /administrator/components/com_virtuemart/models/orders.php:
$data['invoice_number'] = str_replace('-', '', substr(date("H:i:s Y-m-d"),2,8)).substr(md5($orderDetails['order_number'].$orderDetails['order_status']),0,3).'0'.$count;
:)

It was before $data['invoice_number'] = str_replace('-', '', substr(date("Y-m-d"),2,8)).substr(md5($orderDetails['order_number'].$orderDetails['order_status']),0,3).'0'.$count;

and others had trouble

Seems related to j1.5 or j1.6+  or to the php version
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Thomas Kuschel

Quote from: Milbo on March 08, 2012, 16:21:27 PM
It was before $data['invoice_number'] = str_replace('-', '', substr(date("Y-m-d"),2,8)).substr(md5($orderDetails['order_number'].$orderDetails['order_status']),0,3).'0'.$count;

and others had trouble

Seems related to j1.5 or j1.6+  or to the php version

Hi, in the line 993 (models/orders.php)  str_replace('-', '', substr(JFactory::getDate(),2,8)).substr(md5($orderDetails['order_number'].$orderDetails['order_status']),0,3).'0'.$count; the term JFactory::getDate() computes a reference to the class object JDate!
So it is definitely wrong - and the PHP throws an information or error...
Sometimes the md5 function calculates a pure number too, so I changed the line and added some stuff too; no errors, no information any more:

File: administrator/components/com_virtuemart/models/orders.php (line 991)
if(empty($data['invoice_number'])) {
//$variable_fixed=sprintf("%05s",$num_rows);
$_date = JFactory::getDate();
$data['invoice_number'] = str_replace('-', '', substr($_date->toISO8601(),2,8)).substr((string)md5($orderDetails['order_number'].$orderDetails['order_status']),0,3).'0'.$count;
//$data['invoice_number'] = str_replace('-', '', substr(JFactory::getDate(),2,8)).substr(md5($orderDetails['order_number'].$orderDetails['order_status']),0,3).'0'.$count;
}

tested with J1.5, VM2.02, PHP 5.3.10-2, debian
Best regards,
Thomas