Merge pull request #16 from VitalyArt/VitalyArt-bugfix

fix order total
This commit is contained in:
Alex Lushpai 2016-09-26 15:58:24 +03:00 committed by GitHub
commit 09e5fd6e0a

View File

@ -236,8 +236,11 @@ class ModelRetailcrmHistory extends Model
$deliveryCost = !empty($order['delivery']['cost']) ? $order['delivery']['cost'] : 0; $deliveryCost = !empty($order['delivery']['cost']) ? $order['delivery']['cost'] : 0;
$order_totals = $this->model_sale_order->getOrderTotals($order['externalId']);
$total_summ = isset($order['totalSumm']) ? $order['totalSumm'] : $order['summ'] + $deliveryCost;
$data['order_total'] = array( $data['order_total'] = array(
array( 'sub_total' => array(
'order_total_id' => '', 'order_total_id' => '',
'code' => 'sub_total', 'code' => 'sub_total',
'title' => $this->language->get('product_summ'), 'title' => $this->language->get('product_summ'),
@ -245,7 +248,7 @@ class ModelRetailcrmHistory extends Model
'text' => $order['summ'], 'text' => $order['summ'],
'sort_order' => $this->subtotalSettings['sub_total_sort_order'] 'sort_order' => $this->subtotalSettings['sub_total_sort_order']
), ),
array( 'shipping' => array(
'order_total_id' => '', 'order_total_id' => '',
'code' => 'shipping', 'code' => 'shipping',
'title' => $this->ocDelivery[$data['shipping_code']], 'title' => $this->ocDelivery[$data['shipping_code']],
@ -253,16 +256,28 @@ class ModelRetailcrmHistory extends Model
'text' => $deliveryCost, 'text' => $deliveryCost,
'sort_order' => $this->shippingSettings['shipping_sort_order'] 'sort_order' => $this->shippingSettings['shipping_sort_order']
), ),
array( 'total' => array(
'order_total_id' => '', 'order_total_id' => '',
'code' => 'total', 'code' => 'total',
'title' => $this->language->get('column_total'), 'title' => $this->language->get('column_total'),
'value' => isset($order['totalSumm']) ? $order['totalSumm'] : $order['summ'] + $deliveryCost, 'value' => $total_summ,
'text' => isset($order['totalSumm']) ? $order['totalSumm'] : $order['summ'] + $deliveryCost, 'text' => $total_summ,
'sort_order' => $this->totalSettings['total_sort_order'] 'sort_order' => $this->totalSettings['total_sort_order']
) )
); );
foreach ($order_totals as $value) {
if(in_array($value['code'], array_keys($data['order_total']))) {
continue;
}
$data['order_total'][$value['code']] = $value;
$total_summ += $value['value'];
}
$data['order_total']['total']['value'] = $total_summ;
$data['order_total']['total']['text'] = $total_summ;
$data['fromApi'] = true; $data['fromApi'] = true;
if (array_key_exists($order['status'], $this->status)) { if (array_key_exists($order['status'], $this->status)) {