netamis Posted June 1, 2014 Share Posted June 1, 2014 Hello , I need some help regarding orders in Prestashop 1.6. From time to time issues appear when cart is transformed in orders. for eg orders's details are empty ( in database is not inserted as well , invoice are not inserted in database). From back-office I also get occasionally error attached when a cart is transformed in order. My main concern is related with first error - unfortunately - in test I cannot reproduced it. Thank you for helping. Mirela Link to comment Share on other sites More sharing options...
NemoPS Posted June 2, 2014 Share Posted June 2, 2014 You probably need to debug a bit, here is the method public function addOrderPayment($amount_paid, $payment_method = null, $payment_transaction_id = null, $currency = null, $date = null, $order_invoice = null) { $order_payment = new OrderPayment(); $order_payment->order_reference = $this->reference; $order_payment->id_currency = ($currency ? $currency->id : $this->id_currency); // we kept the currency rate for historization reasons $order_payment->conversion_rate = ($currency ? $currency->conversion_rate : 1); // if payment_method is define, we used this $order_payment->payment_method = ($payment_method ? $payment_method : $this->payment); $order_payment->transaction_id = $payment_transaction_id; $order_payment->amount = $amount_paid; $order_payment->date_add = ($date ? $date : null); // Update total_paid_real value for backward compatibility reasons if ($order_payment->id_currency == $this->id_currency) $this->total_paid_real += $order_payment->amount; else $this->total_paid_real += Tools::ps_round(Tools::convertPrice($order_payment->amount, $order_payment->id_currency, false), 2); // We put autodate parameter of add method to true if date_add field is null $res = $order_payment->add(is_null($order_payment->date_add)) && $this->update(); if (!$res) return false; if (!is_null($order_invoice)) { $res = Db::getInstance()->execute(' INSERT INTO `'._DB_PREFIX_.'order_invoice_payment` (`id_order_invoice`, `id_order_payment`, `id_order`) VALUES('.(int)$order_invoice->id.', '.(int)$order_payment->id.', '.(int)$this->id.')'); // Clear cache Cache::clean('order_invoice_paid_*'); } return $res; } It will return false either in the middle or at the end, try adding die('I got here'); after if (!$res) return false; Of course, as it doesn't always happen, you will probably often see the message, but in case you don't sometimes, the problem resides here $res = $order_payment->add(is_null($order_payment->date_add)) && $this->update(); And you have to inspect that other method Link to comment Share on other sites More sharing options...
netamis Posted June 2, 2014 Author Share Posted June 2, 2014 Thank you for advice, really appreciate. Mirela Link to comment Share on other sites More sharing options...
Recommended Posts