mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-24 06:06:06 +03:00
Coupon discount (#58)
This commit is contained in:
parent
023f7f7677
commit
dd3c32ea4c
11
Changelog.md
11
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
|
||||
* Доработана модель получения способов доставки
|
||||
* Устранены ошибки пакетной выгрузки
|
||||
|
@ -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' => '',
|
||||
|
@ -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');
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user