1
0
mirror of synced 2025-01-18 08:51:41 +03:00

ref #90318 Added handling of fatal errors when working with abandoned carts

This commit is contained in:
Uryvskiy Dima 2023-06-14 10:20:07 +03:00
parent 02de28a7f5
commit 0e51289625
6 changed files with 45 additions and 31 deletions

View File

@ -1,3 +1,6 @@
## 2022-06-14 4.6.6
* Added handling of fatal errors when working with abandoned carts
## 2022-06-08 4.6.5 ## 2022-06-08 4.6.5
* Transferring WC meta fields to standard CRM order and customer fields * Transferring WC meta fields to standard CRM order and customer fields

View File

@ -1 +1 @@
4.6.5 4.6.6

View File

@ -408,23 +408,27 @@ if (!class_exists('WC_Retailcrm_Base')) {
{ {
global $woocommerce; global $woocommerce;
$site = $this->apiClient->getSingleSiteForKey(); try {
$cartItems = $woocommerce->cart->get_cart(); $site = $this->apiClient->getSingleSiteForKey();
$customerId = $woocommerce->customer->get_id(); $cartItems = $woocommerce->cart->get_cart();
$customerId = $woocommerce->customer->get_id();
if (empty($site)) { if (empty($site)) {
writeBaseLogs('Error with CRM credentials: need an valid apiKey assigned to one certain site'); writeBaseLogs('Error with CRM credentials: need an valid apiKey assigned to one certain site');
} elseif (empty($customerId)) { } elseif (empty($customerId)) {
writeBaseLogs('Abandoned carts work only for registered customers'); writeBaseLogs('Abandoned carts work only for registered customers');
} else {
$isCartExist = $this->cart->isCartExist($customerId, $site);
$isSuccessful = $this->cart->processCart($customerId, $cartItems, $site, $isCartExist);
if ($isSuccessful) {
writeBaseLogs('Cart for customer ID: ' . $customerId . ' processed. Hook: ' . current_filter());
} else { } else {
writeBaseLogs('Cart for customer ID: ' . $customerId . ' not processed. Hook: ' . current_filter()); $isCartExist = $this->cart->isCartExist($customerId, $site);
$isSuccessful = $this->cart->processCart($customerId, $cartItems, $site, $isCartExist);
if ($isSuccessful) {
writeBaseLogs('Cart for customer ID: ' . $customerId . ' processed. Hook: ' . current_filter());
} else {
writeBaseLogs('Cart for customer ID: ' . $customerId . ' not processed. Hook: ' . current_filter());
}
} }
} catch (Throwable $exception) {
writeBaseLogs($exception->getMessage());
} }
} }
@ -443,22 +447,26 @@ if (!class_exists('WC_Retailcrm_Base')) {
{ {
global $woocommerce; global $woocommerce;
$site = $this->apiClient->getSingleSiteForKey(); try {
$customerId = $woocommerce->customer->get_id(); $site = $this->apiClient->getSingleSiteForKey();
$customerId = $woocommerce->customer->get_id();
if (empty($site)) { if (empty($site)) {
writeBaseLogs('Error with CRM credentials: need an valid apiKey assigned to one certain site'); writeBaseLogs('Error with CRM credentials: need an valid apiKey assigned to one certain site');
} elseif (empty($customerId)) { } elseif (empty($customerId)) {
writeBaseLogs('Abandoned carts work only for registered customers'); writeBaseLogs('Abandoned carts work only for registered customers');
} else { } else {
$isCartExist = $this->cart->isCartExist($customerId, $site); $isCartExist = $this->cart->isCartExist($customerId, $site);
$isSuccessful = $this->cart->clearCart($customerId, $site, $isCartExist); $isSuccessful = $this->cart->clearCart($customerId, $site, $isCartExist);
if ($isSuccessful) { if ($isSuccessful) {
writeBaseLogs('Cart for customer ID: ' . $customerId . ' cleared. Hook: ' . current_filter()); writeBaseLogs('Cart for customer ID: ' . $customerId . ' cleared. Hook: ' . current_filter());
} elseif ($isCartExist) { } elseif ($isCartExist) {
writeBaseLogs('Cart for customer ID: ' . $customerId . ' not cleared. Hook: ' . current_filter()); writeBaseLogs('Cart for customer ID: ' . $customerId . ' not cleared. Hook: ' . current_filter());
}
} }
} catch (Throwable $exception) {
writeBaseLogs($exception->getMessage());
} }
} }

View File

@ -5,7 +5,7 @@ Tags: Интеграция, Simla.com, simla
Requires PHP: 7.0 Requires PHP: 7.0
Requires at least: 5.3 Requires at least: 5.3
Tested up to: 6.0 Tested up to: 6.0
Stable tag: 4.6.5 Stable tag: 4.6.6
License: GPLv1 or later License: GPLv1 or later
License URI: http://www.gnu.org/licenses/gpl-1.0.html License URI: http://www.gnu.org/licenses/gpl-1.0.html
@ -82,6 +82,9 @@ Asegúrate de tener una clave API específica para cada tienda. Las siguientes i
== Changelog == == Changelog ==
= 4.6.6 =
* Added handling of fatal errors when working with abandoned carts
= 4.6.5 = = 4.6.5 =
* Transferring WC meta fields to standard CRM order and customer fields * Transferring WC meta fields to standard CRM order and customer fields

View File

@ -5,7 +5,7 @@
* Description: Integration plugin for WooCommerce & Simla.com * Description: Integration plugin for WooCommerce & Simla.com
* Author: RetailDriver LLC * Author: RetailDriver LLC
* Author URI: http://retailcrm.pro/ * Author URI: http://retailcrm.pro/
* Version: 4.6.5 * Version: 4.6.6
* Tested up to: 6.0 * Tested up to: 6.0
* WC requires at least: 5.4 * WC requires at least: 5.4
* WC tested up to: 6.9 * WC tested up to: 6.9

View File

@ -16,7 +16,7 @@
* *
* @link https://wordpress.org/plugins/woo-retailcrm/ * @link https://wordpress.org/plugins/woo-retailcrm/
* *
* @version 4.6.5 * @version 4.6.6
* *
* @package RetailCRM * @package RetailCRM
*/ */