From 3110960d0674c20a43a988052fe0a2bf69dde5b1 Mon Sep 17 00:00:00 2001 From: Kocmonavtik <61938582+Kocmonavtik@users.noreply.github.com> Date: Wed, 29 Mar 2023 10:36:08 +0300 Subject: [PATCH] ref #88832 Update cart date format (#209) --- CHANGELOG.md | 3 +++ VERSION | 2 +- retailcrm/lib/RetailcrmCartUploader.php | 14 ++++++++++---- retailcrm/retailcrm.php | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15d35b19..95b9044a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v3.5.1 +* Обновление формата даты в корзинах + ## v3.5.0 * Реализована поддержка новой логики работы с брошенными корзинами. diff --git a/VERSION b/VERSION index 1545d966..d5c0c991 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.5.0 +3.5.1 diff --git a/retailcrm/lib/RetailcrmCartUploader.php b/retailcrm/lib/RetailcrmCartUploader.php index 559517b1..5352cda7 100644 --- a/retailcrm/lib/RetailcrmCartUploader.php +++ b/retailcrm/lib/RetailcrmCartUploader.php @@ -76,6 +76,11 @@ class RetailcrmCartUploader */ static $now; + /** + * @var string + */ + static $crmCartDateFormat; + /** * Cast provided sync delay to integer * @@ -101,6 +106,7 @@ public static function init() static::$allowedUpdateInterval = 86400; static::$now = new DateTimeImmutable(); static::$context = Context::getContext(); + static::$crmCartDateFormat = 'Y-m-d H:i:sP'; } /** @@ -148,7 +154,7 @@ public static function run() if ($isExistExternalId) { static::$api->cartClear( [ - 'clearedAt' => date('Y-m-d H:i:s'), + 'clearedAt' => date(static::$crmCartDateFormat), 'customer' => ['externalId' => $cart->id_customer], ], static::$site @@ -256,7 +262,7 @@ private static function buildCrmCart($cart, string $cartExternalId, bool $isExis $crmCart = [ 'customer' => ['externalId' => $cart->id_customer], 'clearAt' => null, - 'createdAt' => $cart->date_add, + 'createdAt' => DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $cart->date_add)->format(static::$crmCartDateFormat), ]; if (!$isExistExternalId) { @@ -264,7 +270,7 @@ private static function buildCrmCart($cart, string $cartExternalId, bool $isExis } if (!empty($cart->date_upd)) { - $crmCart['updatedAt'] = $cart->date_upd; + $crmCart['updatedAt'] = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $cart->date_upd)->format(static::$crmCartDateFormat); } $products = $cart->getProducts(); @@ -280,7 +286,7 @@ private static function buildCrmCart($cart, string $cartExternalId, bool $isExis : $product['id_product'], ], 'quantity' => $product['cart_quantity'], - 'createdAt' => $product['date_add'], + 'createdAt' => DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $product['date_add'])->format(static::$crmCartDateFormat), 'price' => !empty($product['rate']) ? round($product['price'], 2) + (round($product['price'], 2) * $product['rate'] / 100) : round($product['price'], 2), diff --git a/retailcrm/retailcrm.php b/retailcrm/retailcrm.php index 1f657f42..7b8dd811 100644 --- a/retailcrm/retailcrm.php +++ b/retailcrm/retailcrm.php @@ -48,7 +48,7 @@ class RetailCRM extends Module { - const VERSION = '3.5.0'; + const VERSION = '3.5.1'; const API_URL = 'RETAILCRM_ADDRESS'; const API_KEY = 'RETAILCRM_API_TOKEN';