[-] BO : Fix bug #PSCFV-8619 update order weight when modifying products
This commit is contained in:
@@ -24,11 +24,11 @@
|
||||
*}
|
||||
<table class="table" width="100%" cellspacing="0" cellpadding="0" id="shipping_table">
|
||||
<colgroup>
|
||||
<col width="15%">
|
||||
<col width="15%">
|
||||
<col width="">
|
||||
<col width="10%">
|
||||
<col width="20%">
|
||||
<col width="15%"/>
|
||||
<col width="15%"/>
|
||||
<col width=""/>
|
||||
<col width="10%"/>
|
||||
<col width="20%"/>
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -46,7 +46,7 @@
|
||||
<td>{dateFormat date=$line.date_add full=true}</td>
|
||||
<td>{$line.type}</td>
|
||||
<td>{$line.carrier_name}</td>
|
||||
<td>{$line.weight|string_format:"%.3f"} {Configuration::get('PS_WEIGHT_UNIT')}</td>
|
||||
<td class="weight">{$line.weight|string_format:"%.3f"} {Configuration::get('PS_WEIGHT_UNIT')}</td>
|
||||
<td>
|
||||
{if $order->getTaxCalculationMethod() == $smarty.const.PS_TAX_INC}
|
||||
{displayPrice price=$line.shipping_cost_tax_incl currency=$currency->id}
|
||||
|
||||
@@ -1237,12 +1237,11 @@ class OrderCore extends ObjectModel
|
||||
|
||||
public function getTotalWeight()
|
||||
{
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT SUM(product_weight * product_quantity) weight
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT SUM(product_weight * product_quantity)
|
||||
FROM '._DB_PREFIX_.'order_detail
|
||||
WHERE id_order = '.(int)($this->id));
|
||||
|
||||
return (float)($result['weight']);
|
||||
return (float)($result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1881,5 +1880,21 @@ class OrderCore extends ObjectModel
|
||||
$order = new Order($id_order);
|
||||
return $order->getUniqReference();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a unique reference like : GWJTHMZUN#2
|
||||
*
|
||||
* With multishipping, order reference are the same for all orders made with the same cart
|
||||
* in this case this method suffix the order reference by a # and the order number
|
||||
*
|
||||
* @since 1.5.5.0
|
||||
*/
|
||||
public function getIdOrderCarrier()
|
||||
{
|
||||
return (int)Db::getInstance()->getValue('
|
||||
SELECT `id_order_carrier`
|
||||
FROM `'._DB_PREFIX_.'order_carrier`
|
||||
WHERE `id_order` = '.(int)$this->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -489,6 +489,14 @@ class AdminOrdersControllerCore extends AdminController
|
||||
if ($shipping_cost_amount > 0)
|
||||
$amount += $shipping_cost_amount;
|
||||
|
||||
$order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
|
||||
if (Validate::isLoadedObject($order_carrier))
|
||||
{
|
||||
$order_carrier->weight = (float)$order->getTotalWeight();
|
||||
if ($order_carrier->update())
|
||||
$order->weight = sprintf("%.3f ".Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
|
||||
}
|
||||
|
||||
if ($amount > 0)
|
||||
{
|
||||
if (!OrderSlip::createPartialOrderSlip($order, $amount, $shipping_cost_amount, $order_detail_list))
|
||||
@@ -656,6 +664,14 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$order_detail = new OrderDetail((int)$id_order_detail);
|
||||
if (!$order->deleteProduct($order, $order_detail, $qty_cancel_product))
|
||||
$this->errors[] = Tools::displayError('An error occurred while attempting to delete the product.').' <span class="bold">'.$order_detail->product_name.'</span>';
|
||||
// Update weight SUM
|
||||
$order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
|
||||
if (Validate::isLoadedObject($order_carrier))
|
||||
{
|
||||
$order_carrier->weight = (float)$order->getTotalWeight();
|
||||
if ($order_carrier->update())
|
||||
$order->weight = sprintf("%.3f ".Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
|
||||
}
|
||||
Hook::exec('actionProductCancel', array('order' => $order, 'id_order_detail' => (int)$id_order_detail));
|
||||
}
|
||||
if (!count($this->errors) && $customizationList)
|
||||
@@ -914,13 +930,10 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$order_detail->updateTaxAmount($order);
|
||||
}
|
||||
|
||||
$id_order_carrier = Db::getInstance()->getValue('
|
||||
SELECT `id_order_carrier`
|
||||
FROM `'._DB_PREFIX_.'order_carrier`
|
||||
WHERE `id_order` = '.(int)$order->id);
|
||||
$id_order_carrier = (int)$order->getIdOrderCarrier();
|
||||
if ($id_order_carrier)
|
||||
{
|
||||
$order_carrier = new OrderCarrier($id_order_carrier);
|
||||
$order_carrier = $order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
|
||||
$order_carrier->shipping_cost_tax_excl = (float)Tools::convertPriceFull($order_carrier->shipping_cost_tax_excl, $old_currency, $currency);
|
||||
$order_carrier->shipping_cost_tax_incl = (float)Tools::convertPriceFull($order_carrier->shipping_cost_tax_incl, $old_currency, $currency);
|
||||
$order_carrier->update();
|
||||
@@ -1697,6 +1710,15 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
// Save changes of order
|
||||
$order->update();
|
||||
|
||||
// Update weight SUM
|
||||
$order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
|
||||
if (Validate::isLoadedObject($order_carrier))
|
||||
{
|
||||
$order_carrier->weight = (float)$order->getTotalWeight();
|
||||
if ($order_carrier->update())
|
||||
$order->weight = sprintf("%.3f ".Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
|
||||
}
|
||||
|
||||
// Update Tax lines
|
||||
$order_detail->updateTaxAmount($order);
|
||||
@@ -1904,6 +1926,17 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
// Save order detail
|
||||
$res &= $order_detail->update();
|
||||
|
||||
// Update weight SUM
|
||||
$order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
|
||||
if (Validate::isLoadedObject($order_carrier))
|
||||
{
|
||||
$order_carrier->weight = (float)$order->getTotalWeight();
|
||||
$res &= $order_carrier->update();
|
||||
if ($res)
|
||||
$order->weight = sprintf("%.3f ".Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
|
||||
}
|
||||
|
||||
// Save order invoice
|
||||
if (isset($order_invoice))
|
||||
$res &= $order_invoice->update();
|
||||
@@ -1996,12 +2029,22 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$order->total_products_wt -= $order_detail->total_price_tax_incl;
|
||||
|
||||
$res &= $order->update();
|
||||
|
||||
|
||||
// Reinject quantity in stock
|
||||
$this->reinjectQuantity($order_detail, $order_detail->product_quantity);
|
||||
|
||||
// Delete OrderDetail
|
||||
$res &= $order_detail->delete();
|
||||
|
||||
// Update weight SUM
|
||||
$order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
|
||||
if (Validate::isLoadedObject($order_carrier))
|
||||
{
|
||||
$order_carrier->weight = (float)$order->getTotalWeight();
|
||||
$res &= $order_carrier->update();
|
||||
if ($res)
|
||||
$order->weight = sprintf("%.3f ".Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
|
||||
}
|
||||
|
||||
if (!$res)
|
||||
die(Tools::jsonEncode(array(
|
||||
|
||||
@@ -268,6 +268,10 @@ function updateAmounts(order)
|
||||
$(this).html(old_quantity + 1);
|
||||
$(this).fadeIn('slow');
|
||||
});
|
||||
$('#shipping_table .weight').fadeOut('slow', function() {
|
||||
$(this).html(order.weight);
|
||||
$(this).fadeIn('slow');
|
||||
});
|
||||
}
|
||||
|
||||
function closeAddProduct()
|
||||
|
||||
Reference in New Issue
Block a user