1
0
mirror of synced 2025-01-18 00:41:43 +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
* 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;
$site = $this->apiClient->getSingleSiteForKey();
$cartItems = $woocommerce->cart->get_cart();
$customerId = $woocommerce->customer->get_id();
try {
$site = $this->apiClient->getSingleSiteForKey();
$cartItems = $woocommerce->cart->get_cart();
$customerId = $woocommerce->customer->get_id();
if (empty($site)) {
writeBaseLogs('Error with CRM credentials: need an valid apiKey assigned to one certain site');
} elseif (empty($customerId)) {
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());
if (empty($site)) {
writeBaseLogs('Error with CRM credentials: need an valid apiKey assigned to one certain site');
} elseif (empty($customerId)) {
writeBaseLogs('Abandoned carts work only for registered customers');
} 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;
$site = $this->apiClient->getSingleSiteForKey();
$customerId = $woocommerce->customer->get_id();
try {
$site = $this->apiClient->getSingleSiteForKey();
$customerId = $woocommerce->customer->get_id();
if (empty($site)) {
writeBaseLogs('Error with CRM credentials: need an valid apiKey assigned to one certain site');
} elseif (empty($customerId)) {
writeBaseLogs('Abandoned carts work only for registered customers');
} else {
$isCartExist = $this->cart->isCartExist($customerId, $site);
$isSuccessful = $this->cart->clearCart($customerId, $site, $isCartExist);
if (empty($site)) {
writeBaseLogs('Error with CRM credentials: need an valid apiKey assigned to one certain site');
} elseif (empty($customerId)) {
writeBaseLogs('Abandoned carts work only for registered customers');
} else {
$isCartExist = $this->cart->isCartExist($customerId, $site);
$isSuccessful = $this->cart->clearCart($customerId, $site, $isCartExist);
if ($isSuccessful) {
writeBaseLogs('Cart for customer ID: ' . $customerId . ' cleared. Hook: ' . current_filter());
} elseif ($isCartExist) {
writeBaseLogs('Cart for customer ID: ' . $customerId . ' not cleared. Hook: ' . current_filter());
if ($isSuccessful) {
writeBaseLogs('Cart for customer ID: ' . $customerId . ' cleared. Hook: ' . current_filter());
} elseif ($isCartExist) {
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 at least: 5.3
Tested up to: 6.0
Stable tag: 4.6.5
Stable tag: 4.6.6
License: GPLv1 or later
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 ==
= 4.6.6 =
* Added handling of fatal errors when working with abandoned carts
= 4.6.5 =
* Transferring WC meta fields to standard CRM order and customer fields

View File

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

View File

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