mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-22 05:06:07 +03:00
commit
24c6de76ec
@ -1,3 +1,6 @@
|
||||
## v.3.2.2
|
||||
* Убрана генерация externalId покупателя при заказе без регистрации на сайте.
|
||||
|
||||
## v.3.2.1
|
||||
* Изменена логика передачи данных по заказам и клиентам. Контактные данные по доставке передаются в карточку заказа, контактные данные плательщика в карточку клиента.
|
||||
|
||||
|
@ -48,7 +48,7 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
|
||||
/**
|
||||
* Send one order by id
|
||||
*
|
||||
*
|
||||
* @param array $order_data
|
||||
* @param \RetailcrmProxy $retailcrmApiClient
|
||||
*
|
||||
@ -92,7 +92,6 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
|
||||
if (!isset($order['customer']['externalId']) && !isset($order['customer']['id'])) {
|
||||
$new_customer = array(
|
||||
'externalId' => uniqid(),
|
||||
'firstName' => $order_data['firstname'],
|
||||
'lastName' => $order_data['lastname'],
|
||||
'email' => $order_data['email'],
|
||||
@ -128,9 +127,9 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
|
||||
/**
|
||||
* Process order
|
||||
*
|
||||
*
|
||||
* @param array $order_data
|
||||
*
|
||||
*
|
||||
* @return array $order
|
||||
*/
|
||||
private function process($order_data) {
|
||||
|
@ -38,7 +38,6 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
|
||||
if (!isset($order['customer']['externalId']) && !isset($order['customer']['id'])) {
|
||||
$new_customer = array(
|
||||
'externalId' => uniqid(),
|
||||
'firstName' => $data['firstname'],
|
||||
'lastName' => $data['lastname'],
|
||||
'email' => $data['email'],
|
||||
@ -227,7 +226,7 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
'value' => $option['value']
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (!in_array($option['type'], $offerOptions)) continue;
|
||||
foreach($productOptions as $productOption) {
|
||||
if($productOption['product_option_id'] = $option['product_option_id']) {
|
||||
|
@ -183,6 +183,8 @@ class ModelRetailcrmOrderAdminTest extends OpenCartTest
|
||||
$this->assertArrayHasKey('payments', $orderSend);
|
||||
$this->assertArrayHasKey('customerComment', $orderSend);
|
||||
$this->assertArrayHasKey('customer', $orderSend);
|
||||
$this->assertArrayNotHasKey('externalId', $orderSend['customer']);
|
||||
$this->assertArrayHasKey('id', $orderSend['customer']);
|
||||
$this->assertNotEmpty($orderSend['payments']);
|
||||
}
|
||||
}
|
||||
|
@ -163,6 +163,56 @@ class ModelRetailcrmOrderCatalogTest extends OpenCartTest
|
||||
$this->assertArrayHasKey('customerComment', $orderSend);
|
||||
}
|
||||
|
||||
public function testOrderCreateWithoutCustomerTest()
|
||||
{
|
||||
$order_id = self::ORDER_ID;
|
||||
$orderCheckoutModel = $this->loadModel('checkout/order');
|
||||
$orderAccountModel = $this->loadModel('account/order');
|
||||
$order = $orderCheckoutModel->getOrder($order_id);
|
||||
$order['products'] = $orderAccountModel->getOrderProducts($order_id);
|
||||
$order['totals'] = $orderAccountModel->getOrderTotals($order_id);
|
||||
|
||||
foreach($order['products'] as $key => $product) {
|
||||
$order['products'][$key]['option'] = $orderAccountModel->getOrderOptions($product['order_id'], $product['order_product_id']);
|
||||
}
|
||||
|
||||
$responseCustomerCreate = new \RetailcrmApiResponse(
|
||||
201,
|
||||
json_encode(
|
||||
array(
|
||||
'success' => true,
|
||||
'id' => 1
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$responseCustomerList = new \RetailcrmApiResponse(
|
||||
201,
|
||||
json_encode(
|
||||
array(
|
||||
'success' => true,
|
||||
"pagination"=> [
|
||||
"limit"=>20,
|
||||
"totalCount"=> 0,
|
||||
"currentPage"=> 1,
|
||||
"totalPageCount"=> 0
|
||||
],
|
||||
"customers"=> []
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->apiClientMock->expects($this->any())->method('customersList')->willReturn($responseCustomerList);
|
||||
$this->apiClientMock->expects($this->any())->method('customersCreate')->willReturn($responseCustomerCreate);
|
||||
$orderProcess = $this->orderModel->processOrder($order);
|
||||
$orderSend = $this->orderModel->sendToCrm($orderProcess, $this->apiClientMock, $order);
|
||||
|
||||
$this->assertArrayHasKey('customer', $orderSend);
|
||||
$this->assertArrayNotHasKey('externalId', $orderSend['customer']);
|
||||
$this->assertArrayHasKey('id', $orderSend['customer']);
|
||||
$this->assertEquals(1, $orderSend['customer']['id']);
|
||||
}
|
||||
|
||||
protected function setSetting($code, $data, $store_id = 0) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "setting` WHERE store_id = '" . (int)$store_id . "' AND `code` = '" . $this->db->escape($code) . "'");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user