Author Topic: VM2 Object of class JDate could not be converted to string in orders.php Ln 997  (Read 10892 times)

kaiman

  • Beginner
  • *
  • Posts: 6
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

  • Jr. Member
  • **
  • Posts: 83
I am having exactly the same problem.....at the same point

ChrisTrembath

  • Beginner
  • *
  • Posts: 18
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

  • Beginner
  • *
  • Posts: 1
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10000
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
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
Code: [Select]
$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
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Thomas Kuschel

  • Jr. Member
  • **
  • Posts: 81
    • LOYTEC electronics GmbH
It was before
Code: [Select]
$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)
Code: [Select]
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
 

stefanovirgilli

  • Beginner
  • *
  • Posts: 1
It worked for me. Thank you tkuschel.