VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: kaiman on March 01, 2012, 11:11:47 AM

Title: VM2 Object of class JDate could not be converted to string in orders.php Ln 997
Post by: kaiman on March 01, 2012, 11:11:47 AM
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
Title: Re: VM2 Object of class JDate could not be converted to string in orders.php Ln 997
Post by: idbrokers on March 01, 2012, 16:42:01 PM
I am having exactly the same problem.....at the same point
Title: Re: VM2 Object of class JDate could not be converted to string in orders.php Ln 997
Post by: ChrisTrembath on March 02, 2012, 11:09:24 AM
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
Title: Re: VM2 Object of class JDate could not be converted to string in orders.php Ln 997
Post by: 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(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;
:)
Title: Re: VM2 Object of class JDate could not be converted to string in orders.php Ln 997
Post by: Milbo on March 08, 2012, 16:21:27 PM
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
Title: Re: VM2 Object of class JDate could not be converted to string in orders.php Ln 997
Post by: Thomas Kuschel on March 13, 2012, 09:52:29 AM
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
Title: Re: VM2 Object of class JDate could not be converted to string in orders.php Ln 997
Post by: stefanovirgilli on March 17, 2012, 06:01:11 AM
It worked for me. Thank you tkuschel.