The 'isFromCart' parameter was added when creating an order

This commit is contained in:
Uryvskiy Dima 2023-04-24 11:35:37 +03:00 committed by GitHub
parent 3110960d06
commit de9f0720f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 17 deletions

View File

@ -1,3 +1,6 @@
## v3.5.2
* Добавлен признак корзины при создании заказа
## v3.5.1 ## v3.5.1
* Обновление формата даты в корзинах * Обновление формата даты в корзинах

View File

@ -1 +1 @@
3.5.1 3.5.2

View File

@ -396,7 +396,8 @@ class RetailcrmExport
throw new RetailcrmNotFoundException('Order not found'); 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); $apiResponse = static::$api->ordersGet($object->id);
$existingOrder = []; $existingOrder = [];
@ -418,6 +419,29 @@ class RetailcrmExport
} }
if (empty($existingOrder)) { 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); $response = static::$api->ordersCreate($crmOrder);
} else { } else {
$response = static::$api->ordersEdit($crmOrder); $response = static::$api->ordersEdit($crmOrder);

View File

@ -100,8 +100,7 @@ class RetailcrmExportOrdersHelper
$sqlOrdersInfo = 'FROM `' . _DB_PREFIX_ . 'retailcrm_exported_orders` eo $sqlOrdersInfo = 'FROM `' . _DB_PREFIX_ . 'retailcrm_exported_orders` eo
LEFT JOIN `' . _DB_PREFIX_ . 'orders` o on o.`id_order` = eo.`id_order` LEFT JOIN `' . _DB_PREFIX_ . 'orders` o on o.`id_order` = eo.`id_order`
WHERE ( eo.`id_order` IS NULL OR ( 1 ' . Shop::addSqlRestriction(false, 'o') . ' ) )' WHERE ( eo.`id_order` IS NULL OR ( 1 ' . Shop::addSqlRestriction(false, 'o') . ' ) )';
;
if (0 < count($ordersIds)) { if (0 < count($ordersIds)) {
$sqlOrdersInfo .= ' AND (eo.`id_order` IN ( ' . pSQL(implode(', ', $ordersIds)) . ') $sqlOrdersInfo .= ' AND (eo.`id_order` IN ( ' . pSQL(implode(', ', $ordersIds)) . ')

View File

@ -120,8 +120,7 @@ class RetailcrmMissingEvent extends RetailcrmAbstractEvent implements RetailcrmE
} else { } else {
$order['status'] = array_key_exists($orderInstance->current_state, $status) $order['status'] = array_key_exists($orderInstance->current_state, $status)
? $status[$orderInstance->current_state] ? $status[$orderInstance->current_state]
: 'completed' : 'completed';
;
} }
/** /**
@ -134,8 +133,7 @@ class RetailcrmMissingEvent extends RetailcrmAbstractEvent implements RetailcrmE
if ($address instanceof Address) { if ($address instanceof Address) {
$phone = null === $address->phone $phone = null === $address->phone
? null === $address->phone_mobile ? '' : $address->phone_mobile ? null === $address->phone_mobile ? '' : $address->phone_mobile
: $address->phone : $address->phone;
;
$postcode = $address->postcode; $postcode = $address->postcode;
$city = $address->city; $city = $address->city;

View File

@ -48,7 +48,7 @@ require_once dirname(__FILE__) . '/bootstrap.php';
class RetailCRM extends Module class RetailCRM extends Module
{ {
const VERSION = '3.5.1'; const VERSION = '3.5.2';
const API_URL = 'RETAILCRM_ADDRESS'; const API_URL = 'RETAILCRM_ADDRESS';
const API_KEY = 'RETAILCRM_API_TOKEN'; const API_KEY = 'RETAILCRM_API_TOKEN';
@ -203,8 +203,7 @@ class RetailCRM extends Module
&& ($this->use_new_hooks ? $this->registerHook('actionCustomerAccountUpdate') : true) && ($this->use_new_hooks ? $this->registerHook('actionCustomerAccountUpdate') : true)
&& ($this->use_new_hooks ? $this->registerHook('actionValidateCustomerAddressForm') : true) && ($this->use_new_hooks ? $this->registerHook('actionValidateCustomerAddressForm') : true)
&& $this->installDB() && $this->installDB()
&& $this->installTab() && $this->installTab();
;
} }
/** /**
@ -358,8 +357,7 @@ class RetailCRM extends Module
&& Configuration::deleteByName(RetailcrmJobManager::CURRENT_TASK) && Configuration::deleteByName(RetailcrmJobManager::CURRENT_TASK)
&& Configuration::deleteByName(RetailcrmCli::CURRENT_TASK_CLI) && Configuration::deleteByName(RetailcrmCli::CURRENT_TASK_CLI)
&& $this->uninstallDB() && $this->uninstallDB()
&& $this->uninstallTab() && $this->uninstallTab();
;
} }
public function enable($force_all = false) public function enable($force_all = false)
@ -369,8 +367,7 @@ class RetailCRM extends Module
self::updateCrmModuleState($context->shop->id); self::updateCrmModuleState($context->shop->id);
return parent::enable($force_all) return parent::enable($force_all)
&& $this->installTab() && $this->installTab();
;
} }
public function disable($force_all = false) public function disable($force_all = false)

View File

@ -146,8 +146,7 @@ function upgrade_module_3_4_0($module)
'retailcrm/views/templates/admin/settings.tpl', 'retailcrm/views/templates/admin/settings.tpl',
]) ])
&& $module->uninstallOldTabs() && $module->uninstallOldTabs()
&& $module->installTab() && $module->installTab();
;
} }
function retailcrm_convert_old_default_values_format() function retailcrm_convert_old_default_values_format()