diff --git a/Changelog.md b/Changelog.md index a94a8af..abfbc63 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,13 +1,19 @@ Changelog ========= +####v.1.0.1 +* Добавлена передача скидки по купону + +####v.1.0 +* Улучшена модель получения способов доставки +* Устранены ошибки пакетной выгрузки + ####v0.3.0 * Расширена библиотека клиента * Добавлена возможность кастомизации моделей заказа через vqmod * Устранены мелкие баги, проведен рефакторинг кода. - ####v0.2.0 Общие изменения @@ -37,6 +43,3 @@ Changelog * Реализована выгрузка каталога (cron only) * Реализовано получение данных о заказах, сделанных на стороне CRM (cron only) -####v.1.0 -* Доработана модель получения способов доставки -* Устранены ошибки пакетной выгрузки diff --git a/admin/model/retailcrm/history.php b/admin/model/retailcrm/history.php index 5bd93d4..1d5068b 100644 --- a/admin/model/retailcrm/history.php +++ b/admin/model/retailcrm/history.php @@ -231,6 +231,15 @@ class ModelRetailcrmHistory extends Model $deliveryCost = !empty($order['delivery']['cost']) ? $order['delivery']['cost'] : 0; + if(isset($order['discount']) && $order['discount'] > 0) { + $orderTotals = $this->model_sale_order->getOrderTotals($order['externalId']); + foreach($orderTotals as $orderTotal) { + if($orderTotal['code'] == 'coupon') { + $data['order_total'][] = $orderTotal; + } + } + } + $data['order_total'] = array( array( 'order_total_id' => '', diff --git a/catalog/controller/module/retailcrm.php b/catalog/controller/module/retailcrm.php index 27a368f..f3ed5ae 100644 --- a/catalog/controller/module/retailcrm.php +++ b/catalog/controller/module/retailcrm.php @@ -38,6 +38,8 @@ class ControllerModuleRetailcrm extends Controller $data['products'][$key]['option'] = $productOptions; } + $data['totals'] = $this->model_account_order->getOrderTotals($order_id); + if (!isset($data['fromApi'])) { $this->load->model('setting/setting'); $status = $this->model_setting_setting->getSetting('retailcrm'); @@ -45,11 +47,6 @@ class ControllerModuleRetailcrm extends Controller $data['order_status'] = $status['retailcrm_status'][$data['order_status_id']]; } - $data['totals'][] = array( - 'code' => 'shipping', - 'value' => $this->session->data['shipping_method']['cost'] - ); - $this->load->model('retailcrm/order'); $this->model_retailcrm_order->sendToCrm($data, $data['order_id']); } @@ -77,6 +74,8 @@ class ControllerModuleRetailcrm extends Controller $data['products'][$key]['option'] = $productOptions; } + $data['totals'] = $this->model_account_order->getOrderTotals($order_id); + if (!isset($data['fromApi'])) { $this->load->model('setting/setting'); $status = $this->model_setting_setting->getSetting('retailcrm'); diff --git a/catalog/model/retailcrm/order.php b/catalog/model/retailcrm/order.php index 8a5d1b0..8704538 100644 --- a/catalog/model/retailcrm/order.php +++ b/catalog/model/retailcrm/order.php @@ -58,6 +58,9 @@ class ModelRetailcrmOrder extends Model { if ($totals['code'] == 'shipping') { $deliveryCost = $totals['value']; } + if ($totals['code'] == 'coupon') { + $couponTotal = abs($totals['value']); + } } } @@ -72,6 +75,10 @@ class ModelRetailcrmOrder extends Model { $order_data['shipping_iso_code_2'] = $shipping_country['iso_code_2']; } + if (isset($couponTotal)) { + $order['discount'] = $couponTotal; + } + $delivery_code = $order_data['shipping_code']; $order['delivery'] = array( 'code' => !empty($delivery_code) ? $settings['retailcrm_delivery'][$delivery_code] : '', @@ -182,6 +189,9 @@ class ModelRetailcrmOrder extends Model { if ($totals['code'] == 'shipping') { $deliveryCost = $totals['value']; } + if ($totals['code'] == 'coupon') { + $couponTotal = abs($totals['value']); + } } $order['createdAt'] = $order_data['date_added']; @@ -189,6 +199,10 @@ class ModelRetailcrmOrder extends Model { $country = (isset($order_data['shipping_country'])) ? $order_data['shipping_country'] : '' ; + if (isset($couponTotal)) { + $order['discount'] = $couponTotal; + } + $order['delivery'] = array( 'code' => !empty($delivery_code) ? $settings['retailcrm_delivery'][$delivery_code] : '', 'cost' => $deliveryCost,