mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-03-01 19:03:14 +03:00
create order on edit if it's not present in retailCRM
This commit is contained in:
parent
36a9c12bf8
commit
5108111654
@ -513,7 +513,25 @@ class RetailCRM extends Module
|
||||
RetailcrmLogger::writeNoCaller($exception->getTraceAsString());
|
||||
}
|
||||
|
||||
$orderCrm = $this->api->ordersGet($order['externalId']);
|
||||
|
||||
if (!($orderCrm instanceof RetailcrmApiResponse) || !$orderCrm->isSuccessful()) {
|
||||
/** @var Order|\OrderCore $order */
|
||||
$order = $params['order'];
|
||||
|
||||
$this->hookNewOrder(array(
|
||||
'orderStatus' => $order->current_state,
|
||||
'id_order' => (int) $order->id,
|
||||
'order' => $order,
|
||||
'cart' => new Cart($order->id_cart),
|
||||
'customer' => new Customer($order->id_customer)
|
||||
));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$comment = $orderdb->getFirstMessage();
|
||||
|
||||
if ($comment !== false) {
|
||||
$order['customerComment'] = $comment;
|
||||
}
|
||||
|
@ -11,7 +11,15 @@ class RetailCRMTest extends RetailcrmTestCase
|
||||
|
||||
$this->setConfig();
|
||||
|
||||
$this->apiMock = $this->getMockBuilder('RetailcrmProxy')
|
||||
$this->apiMock = $this->apiMockBuilder()->getMock();
|
||||
|
||||
$this->retailcrmModule = new RetailCRM();
|
||||
$this->retailcrmModule->api = $this->apiMock;
|
||||
}
|
||||
|
||||
private function apiMockBuilder()
|
||||
{
|
||||
return $this->getMockBuilder('RetailcrmProxy')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(
|
||||
array(
|
||||
@ -24,11 +32,7 @@ class RetailCRMTest extends RetailcrmTestCase
|
||||
'ordersPaymentEdit',
|
||||
'ordersPaymentCreate'
|
||||
)
|
||||
)
|
||||
->getMock();
|
||||
|
||||
$this->retailcrmModule = new RetailCRM();
|
||||
$this->retailcrmModule->api = $this->apiMock;
|
||||
);
|
||||
}
|
||||
|
||||
public function testHookActionCustomerAccountAdd()
|
||||
@ -52,6 +56,13 @@ class RetailCRMTest extends RetailcrmTestCase
|
||||
$order = new Order(1);
|
||||
$customer = new Customer($order->id_customer);
|
||||
$params = array('order' => $order, 'customer' => $customer);
|
||||
$this->apiMock->expects($this->any())->method('ordersGet')->willReturn(new RetailcrmApiResponse(
|
||||
200,
|
||||
json_encode(array(
|
||||
'success' => true,
|
||||
'order' => array()
|
||||
))
|
||||
));
|
||||
|
||||
$this->assertTrue($this->retailcrmModule->hookActionOrderEdited($params));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user