mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-04-11 12:50:55 +00:00
The 'isFromCart' parameter was added when creating an order
This commit is contained in:
parent
3110960d06
commit
d77c03ffde
4 changed files with 30 additions and 3 deletions
|
@ -1,3 +1,6 @@
|
|||
## v3.5.2
|
||||
* Добавлен признак корзины при создании заказа
|
||||
|
||||
## v3.5.1
|
||||
* Обновление формата даты в корзинах
|
||||
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
3.5.1
|
||||
3.5.2
|
||||
|
|
|
@ -396,7 +396,8 @@ class RetailcrmExport
|
|||
throw new RetailcrmNotFoundException('Order not found');
|
||||
}
|
||||
|
||||
$customer = new Customer($object->id_customer);
|
||||
$customerId = $object->id_customer;
|
||||
$customer = new Customer($customerId);
|
||||
$apiResponse = static::$api->ordersGet($object->id);
|
||||
$existingOrder = [];
|
||||
|
||||
|
@ -418,6 +419,29 @@ class RetailcrmExport
|
|||
}
|
||||
|
||||
if (empty($existingOrder)) {
|
||||
try {
|
||||
$reference = new RetailcrmReferences(static::$api);
|
||||
$site = $reference->getSite()['code'];
|
||||
$crmCart = static::$api->cartGet($customerId, $site);
|
||||
|
||||
if (!empty($crmCart['cart'])) {
|
||||
// If the order is from a corporate customer, need to clear the cart for the contact person
|
||||
if (!empty($crmOrder['contragent']['legalName']) && !empty($crmOrder['contact'])) {
|
||||
static::$api->cartClear(
|
||||
[
|
||||
'clearedAt' => date('Y-m-d H:i:sP'),
|
||||
'customer' => ['externalId' => $customerId],
|
||||
],
|
||||
$site
|
||||
);
|
||||
} else {
|
||||
$crmOrder['isFromCart'] = true;
|
||||
}
|
||||
}
|
||||
} catch (Throwable $exception) {
|
||||
self::handleError($customerId, $exception);
|
||||
}
|
||||
|
||||
$response = static::$api->ordersCreate($crmOrder);
|
||||
} else {
|
||||
$response = static::$api->ordersEdit($crmOrder);
|
||||
|
|
|
@ -48,7 +48,7 @@ require_once dirname(__FILE__) . '/bootstrap.php';
|
|||
|
||||
class RetailCRM extends Module
|
||||
{
|
||||
const VERSION = '3.5.1';
|
||||
const VERSION = '3.5.2';
|
||||
|
||||
const API_URL = 'RETAILCRM_ADDRESS';
|
||||
const API_KEY = 'RETAILCRM_API_TOKEN';
|
||||
|
|
Loading…
Add table
Reference in a new issue