Fix response status check for abandoned carts

This commit is contained in:
Dima Uryvskiy 2022-11-23 11:36:21 +03:00 committed by GitHub
parent 683e00e851
commit 96f62b5e7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 26 deletions

View File

@ -1,3 +1,6 @@
## v3.4.14
* Исправлен баг при передаче брошенных корзин.
## v3.4.13
* Добавлена передача информации о модуле в CRM при его установке

View File

@ -1 +1 @@
3.4.13
3.4.14

View File

@ -149,35 +149,33 @@ class RetailcrmCartUploader
$response = static::$api->ordersGet($cartExternalId);
if (!($response instanceof RetailcrmApiResponse)) {
// TODO
// Extract address from cart (if exists) and append to customer?
// Or maybe this customer will not order anything, so we don't need it's address...
static::$api->customersCreate(RetailcrmOrderBuilder::buildCrmCustomer(new Customer($cart->id_customer)));
if ($response instanceof RetailcrmApiResponse) {
if (empty($response['order'])) {
// TODO
// Extract address from cart (if exists) and append to customer?
// Or maybe this customer will not order anything, so we don't need it's address...
static::$api->customersCreate(RetailcrmOrderBuilder::buildCrmCustomer(new Customer($cart->id_customer)));
$order = static::buildCartOrder($cart, $cartExternalId);
$order = static::buildCartOrder($cart, $cartExternalId);
if (empty($order)) {
continue;
}
if (empty($order)) {
continue;
}
if (false !== static::$api->ordersCreate($order)) {
$cart->date_upd = date('Y-m-d H:i:s');
$cart->save();
}
if (false !== static::$api->ordersCreate($order)) {
$cart->date_upd = date('Y-m-d H:i:s');
$cart->save();
}
} elseif (!empty($response['order']['externalId'])) {
$order = static::buildCartOrder($cart, $response['order']['externalId']);
continue;
}
if (empty($order)) {
continue;
}
if (isset($response['order']) && !empty($response['order'])) {
$order = static::buildCartOrder($cart, $response['order']['externalId']);
if (empty($order)) {
continue;
}
if (false !== static::$api->ordersEdit($order)) {
static::registerAbandonedCartSync($cart->id);
if (false !== static::$api->ordersEdit($order)) {
static::registerAbandonedCartSync($cart->id);
}
}
}
}

View File

@ -48,7 +48,7 @@ require_once dirname(__FILE__) . '/bootstrap.php';
class RetailCRM extends Module
{
const VERSION = '3.4.13';
const VERSION = '3.4.14';
const API_URL = 'RETAILCRM_ADDRESS';
const API_KEY = 'RETAILCRM_API_TOKEN';