mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-25 22:56:07 +03:00
commit
702c18d757
@ -1,6 +1,7 @@
|
|||||||
## v.3.3.0
|
## v.3.3.0
|
||||||
* Добавена настройка записи истории изменения заказов в Opencart
|
* Добавена настройка записи истории изменения заказов в Opencart
|
||||||
* Устранен баг с вызовом события редактирования заказа при выгрузке истории изменений из retailCRM
|
* Устранен баг с вызовом события редактирования заказа при выгрузке истории изменений из retailCRM
|
||||||
|
* Добавлена передача типа цены при создании и редактировании заказа
|
||||||
|
|
||||||
## v.3.2.4
|
## v.3.2.4
|
||||||
* Добавлена возможность передачи акционных цен для нескольких групп пользователей
|
* Добавлена возможность передачи акционных цен для нескольких групп пользователей
|
||||||
|
@ -92,6 +92,8 @@ class ModelExtensionRetailcrmOrder extends Model {
|
|||||||
public function processOrder($order_data, $create = true) {
|
public function processOrder($order_data, $create = true) {
|
||||||
$this->load->model('setting/setting');
|
$this->load->model('setting/setting');
|
||||||
$this->load->model('catalog/product');
|
$this->load->model('catalog/product');
|
||||||
|
$this->load->model('account/customer');
|
||||||
|
$this->load->model('extension/retailcrm/product');
|
||||||
$this->settings = $this->model_setting_setting->getSetting($this->moduleTitle);
|
$this->settings = $this->model_setting_setting->getSetting($this->moduleTitle);
|
||||||
$order_id = $order_data['order_id'];
|
$order_id = $order_data['order_id'];
|
||||||
|
|
||||||
@ -255,8 +257,24 @@ class ModelExtensionRetailcrmOrder extends Model {
|
|||||||
),
|
),
|
||||||
'productName' => $product['name'],
|
'productName' => $product['name'],
|
||||||
'initialPrice' => $product['price'],
|
'initialPrice' => $product['price'],
|
||||||
'quantity' => $product['quantity'],
|
'quantity' => $product['quantity']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$specials = $this->model_extension_retailcrm_product->getProductSpecials($product['product_id']);
|
||||||
|
|
||||||
|
if (!empty($specials)) {
|
||||||
|
$customer = $this->model_account_customer->getCustomer($order_data['customer_id']);
|
||||||
|
|
||||||
|
foreach ($specials as $special) {
|
||||||
|
if (isset($customer['customer_group_id'])) {
|
||||||
|
if ($special['customer_group_id'] == $customer['customer_group_id']) {
|
||||||
|
if ($this->settings[$this->moduleTitle . '_special_' . $customer['customer_group_id']]) {
|
||||||
|
$item['priceType']['code'] = $this->settings[$this->moduleTitle . '_special_' . $customer['customer_group_id']];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$item = array(
|
$item = array(
|
||||||
'productName' => $product['name'],
|
'productName' => $product['name'],
|
||||||
|
10
src/upload/catalog/model/extension/retailcrm/product.php
Normal file
10
src/upload/catalog/model/extension/retailcrm/product.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class ModelExtensionRetailcrmProduct extends Model
|
||||||
|
{
|
||||||
|
public function getProductSpecials($product_id) {
|
||||||
|
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$product_id . "' ORDER BY priority, price");
|
||||||
|
|
||||||
|
return $query->rows;
|
||||||
|
}
|
||||||
|
}
|
@ -43,7 +43,10 @@ class ModelRetailcrmOrderCatalogTest extends OpenCartTest
|
|||||||
),
|
),
|
||||||
$this->retailcrm->getModuleTitle() . '_payment' => array(
|
$this->retailcrm->getModuleTitle() . '_payment' => array(
|
||||||
'cod' => 'cod'
|
'cod' => 'cod'
|
||||||
)
|
),
|
||||||
|
$this->retailcrm->getModuleTitle() . '_special_1' => 'special1',
|
||||||
|
$this->retailcrm->getModuleTitle() . '_special_2' => 'special2',
|
||||||
|
$this->retailcrm->getModuleTitle() . '_special_3' => 'special3'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -88,6 +91,12 @@ class ModelRetailcrmOrderCatalogTest extends OpenCartTest
|
|||||||
$this->assertEquals('Rostov-na-Donu', $orderSend['delivery']['address']['region']);
|
$this->assertEquals('Rostov-na-Donu', $orderSend['delivery']['address']['region']);
|
||||||
$this->assertEquals('111111', $orderSend['delivery']['address']['index']);
|
$this->assertEquals('111111', $orderSend['delivery']['address']['index']);
|
||||||
$this->assertArrayHasKey('items', $orderSend);
|
$this->assertArrayHasKey('items', $orderSend);
|
||||||
|
|
||||||
|
foreach($orderSend['items'] as $item) {
|
||||||
|
$this->assertArrayHasKey('priceType', $item);
|
||||||
|
$this->assertEquals('special1', $item['priceType']['code']);
|
||||||
|
}
|
||||||
|
|
||||||
$this->assertArrayHasKey('customerComment', $orderSend);
|
$this->assertArrayHasKey('customerComment', $orderSend);
|
||||||
$this->assertArrayHasKey('customer', $orderSend);
|
$this->assertArrayHasKey('customer', $orderSend);
|
||||||
$this->assertArrayHasKey('externalId', $orderSend['customer']);
|
$this->assertArrayHasKey('externalId', $orderSend['customer']);
|
||||||
@ -160,6 +169,12 @@ class ModelRetailcrmOrderCatalogTest extends OpenCartTest
|
|||||||
$this->assertEquals('Rostov-na-Donu', $orderSend['delivery']['address']['region']);
|
$this->assertEquals('Rostov-na-Donu', $orderSend['delivery']['address']['region']);
|
||||||
$this->assertEquals('111111', $orderSend['delivery']['address']['index']);
|
$this->assertEquals('111111', $orderSend['delivery']['address']['index']);
|
||||||
$this->assertArrayHasKey('items', $orderSend);
|
$this->assertArrayHasKey('items', $orderSend);
|
||||||
|
|
||||||
|
foreach($orderSend['items'] as $item) {
|
||||||
|
$this->assertArrayHasKey('priceType', $item);
|
||||||
|
$this->assertEquals('special1', $item['priceType']['code']);
|
||||||
|
}
|
||||||
|
|
||||||
$this->assertArrayHasKey('customerComment', $orderSend);
|
$this->assertArrayHasKey('customerComment', $orderSend);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,6 +226,10 @@ class ModelRetailcrmOrderCatalogTest extends OpenCartTest
|
|||||||
$this->assertArrayNotHasKey('externalId', $orderSend['customer']);
|
$this->assertArrayNotHasKey('externalId', $orderSend['customer']);
|
||||||
$this->assertArrayHasKey('id', $orderSend['customer']);
|
$this->assertArrayHasKey('id', $orderSend['customer']);
|
||||||
$this->assertEquals(1, $orderSend['customer']['id']);
|
$this->assertEquals(1, $orderSend['customer']['id']);
|
||||||
|
|
||||||
|
foreach($orderSend['items'] as $item) {
|
||||||
|
$this->assertArrayNotHasKey('priceType', $item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setSetting($code, $data, $store_id = 0) {
|
protected function setSetting($code, $data, $store_id = 0) {
|
||||||
|
@ -51,5 +51,6 @@ INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `va
|
|||||||
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('163', '1', 'total', 'Total', '106.0000', '9');
|
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('163', '1', 'total', 'Total', '106.0000', '9');
|
||||||
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('166', '2', 'total', 'Total', '85.0000', '9');
|
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('166', '2', 'total', 'Total', '85.0000', '9');
|
||||||
INSERT INTO `oc_product_special` (`product_id`, `customer_group_id`, `priority`, `price`,`date_start`, `date_end`) values ('42', '2', '1', '110.000', CURDATE(), ADDDATE(CURDATE(),INTERVAL 10 DAY));
|
INSERT INTO `oc_product_special` (`product_id`, `customer_group_id`, `priority`, `price`,`date_start`, `date_end`) values ('42', '2', '1', '110.000', CURDATE(), ADDDATE(CURDATE(),INTERVAL 10 DAY));
|
||||||
|
INSERT INTO `oc_product_special` (`product_id`, `customer_group_id`, `priority`, `price`,`date_start`, `date_end`) values ('40', '1', '1', '50.000', CURDATE(), ADDDATE(CURDATE(),INTERVAL 10 DAY));
|
||||||
|
|
||||||
TRUNCATE TABLE `oc_order_voucher`;
|
TRUNCATE TABLE `oc_order_voucher`;
|
Loading…
Reference in New Issue
Block a user