diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d3090b..3296c65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/VERSION b/VERSION index d9167bb..b3a44c1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.6.5 \ No newline at end of file +4.6.6 \ No newline at end of file diff --git a/src/include/class-wc-retailcrm-base.php b/src/include/class-wc-retailcrm-base.php index 4cd4be9..fcb6506 100644 --- a/src/include/class-wc-retailcrm-base.php +++ b/src/include/class-wc-retailcrm-base.php @@ -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()); } } diff --git a/src/readme.txt b/src/readme.txt index dd46a75..76f9a26 100644 --- a/src/readme.txt +++ b/src/readme.txt @@ -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 diff --git a/src/retailcrm.php b/src/retailcrm.php index bebd20c..9894602 100644 --- a/src/retailcrm.php +++ b/src/retailcrm.php @@ -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 diff --git a/src/uninstall.php b/src/uninstall.php index 67f2a1a..5447e0c 100644 --- a/src/uninstall.php +++ b/src/uninstall.php @@ -16,7 +16,7 @@ * * @link https://wordpress.org/plugins/woo-retailcrm/ * - * @version 4.6.5 + * @version 4.6.6 * * @package RetailCRM */