// Small fix
This commit is contained in:
+10
-9
@@ -1132,19 +1132,20 @@ class OrderCore extends ObjectModel
|
||||
// Update order payment
|
||||
if ($use_existing_payment)
|
||||
{
|
||||
$id_order_payment = Db::getInstance()->getValue('
|
||||
SELECT MAX(id_order_payment) FROM `'._DB_PREFIX_.'order_payment` op
|
||||
$id_order_payments = Db::getInstance()->executeS('
|
||||
SELECT id_order_payment FROM `'._DB_PREFIX_.'order_payment` op
|
||||
INNER JOIN `'._DB_PREFIX_.'orders` o
|
||||
ON o.reference = op.order_reference
|
||||
WHERE id_order = '.(int)$order_invoice->id_order);
|
||||
|
||||
if ($id_order_payment)
|
||||
Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'order_invoice_payment`
|
||||
SET
|
||||
`id_order_invoice` = '.(int)$order_invoice->id.',
|
||||
`id_order_payment` = '.(int)$id_order_payment.',
|
||||
`id_order` = '.(int)$order_invoice->id_order);
|
||||
if (count($id_order_payments))
|
||||
foreach ($id_order_payments as $order_payment)
|
||||
Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'order_invoice_payment`
|
||||
SET
|
||||
`id_order_invoice` = '.(int)$order_invoice->id.',
|
||||
`id_order_payment` = '.(int)$order_payment['id_order_payment'].',
|
||||
`id_order` = '.(int)$order_invoice->id_order);
|
||||
}
|
||||
|
||||
// Update order cart rule
|
||||
|
||||
@@ -338,7 +338,12 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = $order->id;
|
||||
$history->id_employee = (int)$this->context->employee->id;
|
||||
$history->changeIdOrderState($order_state->id, $order->id);
|
||||
|
||||
$use_existings_payment = false;
|
||||
if (!$order->hasInvoice())
|
||||
$use_existings_payment = true;
|
||||
$history->changeIdOrderState($order_state->id, $order->id, true);
|
||||
|
||||
$carrier = new Carrier($order->id_carrier, $order->id_lang);
|
||||
$templateVars = array();
|
||||
if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') && $order->shipping_number)
|
||||
@@ -996,7 +1001,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$this->errors[] = Tools::displayError('This order already has an invoice');
|
||||
else
|
||||
{
|
||||
$order->setInvoice();
|
||||
$order->setInvoice(true);
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user