mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-24 06:06:06 +03:00
Bonus points, fix customer group in history
This commit is contained in:
parent
784677cc9c
commit
98b485cba0
@ -1,3 +1,7 @@
|
||||
## v.2.0.5
|
||||
* Добавлена проверка группы пользователя в заказе при редактировании
|
||||
* Добавлена передача скидки по бонусным баллам
|
||||
|
||||
## v.2.0.4
|
||||
* Исправление мелких багов
|
||||
|
||||
|
@ -41,7 +41,6 @@ class ModelRetailcrmBaseHistory extends Model
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "order` SET customer_id = '" . (int)$order['customer_id'] . "', customer_group_id = '" . (int)$order['customer_group_id'] . "', firstname = '" . $this->db->escape($order['firstname']) . "', lastname = '" . $this->db->escape($order['lastname']) . "', email = '" . $this->db->escape($order['email']) . "', telephone = '" . $this->db->escape($order['telephone']) . "', custom_field = '" . $this->db->escape(json_encode($order['custom_field'])) . "', payment_firstname = '" . $this->db->escape($order['payment_firstname']) . "', payment_lastname = '" . $this->db->escape($order['payment_lastname']) . "', payment_address_1 = '" . $this->db->escape($order['payment_address_1']) . "', payment_address_2 = '" . $this->db->escape($order['payment_address_2']) . "', payment_city = '" . $this->db->escape($order['payment_city']) . "', payment_postcode = '" . $this->db->escape($order['payment_postcode']) . "', payment_country = '" . $this->db->escape($order['payment_country']) . "', payment_country_id = '" . (int)$order['payment_country_id'] . "', payment_zone = '" . $this->db->escape($order['payment_zone']) . "', payment_zone_id = '" . (int)$order['payment_zone_id'] . "', payment_method = '" . $this->db->escape($order['payment_method']) . "', payment_code = '" . $this->db->escape($order['payment_code']) . "', shipping_firstname = '" . $this->db->escape($order['shipping_firstname']) . "', shipping_lastname = '" . $this->db->escape($order['shipping_lastname']) . "', shipping_address_1 = '" . $this->db->escape($order['shipping_address_1']) . "', shipping_address_2 = '" . $this->db->escape($order['shipping_address_2']) . "', shipping_city = '" . $this->db->escape($order['shipping_city']) . "', shipping_postcode = '" . $this->db->escape($order['shipping_postcode']) . "', shipping_country = '" . $this->db->escape($order['shipping_country']) . "', shipping_country_id = '" . (int)$order['shipping_country_id'] . "', shipping_zone = '" . $this->db->escape($order['shipping_zone']) . "', shipping_zone_id = '" . (int)$order['shipping_zone_id'] . "', shipping_method = '" . $this->db->escape($order['shipping_method']) . "', shipping_code = '" . $this->db->escape($order['shipping_code']) . "', comment = '" . $this->db->escape($order['comment']) . "', total = '" . (float)$order['total'] . "', order_status_id = '" . (int)$order['order_status_id'] . "', date_modified = NOW() WHERE order_id = '" . (int)$order_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "'");
|
||||
|
||||
// Products
|
||||
if (isset($order['order_product']) && $order['order_product']) {
|
||||
|
@ -141,9 +141,17 @@ class ModelRetailcrmHistory extends ModelRetailcrmBaseHistory
|
||||
$data['telephone'] = $phone;
|
||||
}
|
||||
|
||||
if (isset($order['customer']['externalId']) && $order['customer']['externalId']) {
|
||||
if (version_compare(VERSION, '2.1.0.0', '>=')) {
|
||||
$customer = $this->model_customer_customer->getCustomer($order['customer']['externalId']);
|
||||
} else {
|
||||
$customer = $this->model_sale_customer->getCustomer($order['customer']['externalId']);
|
||||
}
|
||||
}
|
||||
|
||||
$data['customer'] = $order['firstName'];
|
||||
$data['customer_id'] = (!empty($order['customer']['externalId'])) ? $order['customer']['externalId'] : 0;
|
||||
$data['customer_group_id'] = 1;
|
||||
$data['customer_group_id'] = (isset($customer)) ? $customer['customer_group_id'] : 1;
|
||||
$data['firstname'] = $order['firstName'];
|
||||
$data['lastname'] = isset($order['lastName']) ? $order['lastName'] : $order['firstName'];
|
||||
$data['email'] = $mail ? $mail : uniqid() . '@retailrcm.ru';
|
||||
@ -225,6 +233,10 @@ class ModelRetailcrmHistory extends ModelRetailcrmBaseHistory
|
||||
}
|
||||
|
||||
$data['shipping_code'] = $data['shipping'];
|
||||
} elseif (!isset($this->settings['retailcrm_delivery'][$ocOrder['shipping_code']])
|
||||
) {
|
||||
$data['shipping_method'] = $ocOrder['shipping_method'];
|
||||
$data['shipping_code'] = $ocOrder['shipping_code'];
|
||||
}
|
||||
} else {
|
||||
if (!isset($this->settings[$ocOrder['shipping_code']])
|
||||
@ -310,15 +322,6 @@ class ModelRetailcrmHistory extends ModelRetailcrmBaseHistory
|
||||
|
||||
$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['total'] = $order['totalSumm'];
|
||||
$data['order_total'] = array(
|
||||
array(
|
||||
@ -347,6 +350,17 @@ class ModelRetailcrmHistory extends ModelRetailcrmBaseHistory
|
||||
)
|
||||
);
|
||||
|
||||
if (isset($order['discount']) && $order['discount'] > 0) {
|
||||
$orderTotals = $this->model_sale_order->getOrderTotals($order['externalId']);
|
||||
foreach($orderTotals as $orderTotal) {
|
||||
if ($orderTotal['code'] == 'coupon'
|
||||
|| $orderTotal['code'] == 'reward'
|
||||
) {
|
||||
$data['order_total'][] = $orderTotal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data['fromApi'] = true;
|
||||
|
||||
if (array_key_exists($order['status'], $this->status)) {
|
||||
|
@ -50,6 +50,7 @@ class ModelRetailcrmOrder extends Model {
|
||||
}
|
||||
|
||||
$deliveryCost = 0;
|
||||
$couponTotal = 0;
|
||||
$altTotals = isset($order_data['order_total']) ? $order_data['order_total'] : "";
|
||||
$orderTotals = isset($order_data['totals']) ? $order_data['totals'] : $altTotals ;
|
||||
|
||||
@ -59,7 +60,10 @@ class ModelRetailcrmOrder extends Model {
|
||||
$deliveryCost = $totals['value'];
|
||||
}
|
||||
if ($totals['code'] == 'coupon') {
|
||||
$couponTotal = abs($totals['value']);
|
||||
$couponTotal += abs($totals['value']);
|
||||
}
|
||||
if ($totals['code'] == 'reward') {
|
||||
$couponTotal += abs($totals['value']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -75,7 +79,7 @@ class ModelRetailcrmOrder extends Model {
|
||||
$order_data['shipping_iso_code_2'] = $shipping_country['iso_code_2'];
|
||||
}
|
||||
|
||||
if (isset($couponTotal)) {
|
||||
if (isset($couponTotal) && $couponTotal > 0) {
|
||||
$order['discount'] = $couponTotal;
|
||||
}
|
||||
|
||||
@ -183,6 +187,7 @@ class ModelRetailcrmOrder extends Model {
|
||||
}
|
||||
|
||||
$deliveryCost = 0;
|
||||
$couponTotal = 0;
|
||||
$orderTotals = isset($order_data['totals']) ? $order_data['totals'] : $order_data['order_total'] ;
|
||||
|
||||
foreach ($orderTotals as $totals) {
|
||||
@ -190,7 +195,10 @@ class ModelRetailcrmOrder extends Model {
|
||||
$deliveryCost = $totals['value'];
|
||||
}
|
||||
if ($totals['code'] == 'coupon') {
|
||||
$couponTotal = abs($totals['value']);
|
||||
$couponTotal += abs($totals['value']);
|
||||
}
|
||||
if ($totals['code'] == 'reward') {
|
||||
$couponTotal += abs($totals['value']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,7 +207,7 @@ class ModelRetailcrmOrder extends Model {
|
||||
|
||||
$country = (isset($order_data['shipping_country'])) ? $order_data['shipping_country'] : '' ;
|
||||
|
||||
if (isset($couponTotal)) {
|
||||
if (isset($couponTotal) && $couponTotal > 0) {
|
||||
$order['discount'] = $couponTotal;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user