From a84b7261d23d814416899907432cecd895755444 Mon Sep 17 00:00:00 2001 From: Kocmonavtik <61938582+Kocmonavtik@users.noreply.github.com> Date: Wed, 17 May 2023 15:33:12 +0300 Subject: [PATCH] =?UTF-8?q?ref=20#88866=20=D0=94=D0=BE=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=B0=D0=BD=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B0?= =?UTF-8?q?=D0=B4=D1=80=D0=B5=D1=81=D0=B0=20=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7?= =?UTF-8?q?=D0=B0=20=D0=BF=D0=BE=20=D0=B8=D1=81=D1=82=D0=BE=D1=80=D0=B8?= =?UTF-8?q?=D0=B8=20(#303)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ VERSION | 2 +- src/include/class-wc-retailcrm-history.php | 10 ++++++++-- src/readme.txt | 5 ++++- src/retailcrm.php | 2 +- src/uninstall.php | 2 +- tests/test-wc-retailcrm-history.php | 21 +++++++++++++++++++++ 7 files changed, 39 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9690a1..f140678 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2022-05-17 4.6.2 +* Modified method getting an address by history + ## 2022-04-25 4.6.1 * The algorithm for getting the history of orders and customers has been optimized diff --git a/VERSION b/VERSION index f4fa8fc..3208b09 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.6.1 \ No newline at end of file +4.6.2 \ No newline at end of file diff --git a/src/include/class-wc-retailcrm-history.php b/src/include/class-wc-retailcrm-history.php index 50308d5..f1739d7 100644 --- a/src/include/class-wc-retailcrm-history.php +++ b/src/include/class-wc-retailcrm-history.php @@ -997,12 +997,16 @@ if (!class_exists('WC_Retailcrm_History')) : /** * Returns data for address_1 and address_2(if exist data for this field) for WC order. * - * @param string $addressLine + * @param string|null $addressLine * * @return mixed */ - private function getAddressLines(string $addressLine) + private function getAddressLines($addressLine) { + if ($addressLine === null) { + return null; + } + if (strpos($addressLine, WC_Retailcrm_Abstracts_Address::ADDRESS_LINE_DIVIDER) !== false) { $addressLines = explode(WC_Retailcrm_Abstracts_Address::ADDRESS_LINE_DIVIDER, $addressLine); @@ -1183,6 +1187,7 @@ if (!class_exists('WC_Retailcrm_History')) : $result->save(); $handled = true; + // @codeCoverageIgnoreStart } catch (\Exception $exception) { $errorMessage = sprintf( 'Error switching order externalId=%s to customer id=%s (new company: id=%s %s). Reason: %s', @@ -1201,6 +1206,7 @@ if (!class_exists('WC_Retailcrm_History')) : )); $handled = false; } + // @codeCoverageIgnoreEnd } return $handled; diff --git a/src/readme.txt b/src/readme.txt index 3ac93bc..c52f069 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.1 +Stable tag: 4.6.2 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.2 = +* Modified method getting an address by history + = 4.6.1 = * The algorithm for getting the history of orders and customers has been optimized diff --git a/src/retailcrm.php b/src/retailcrm.php index 1446be9..7b07f2f 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.1 + * Version: 4.6.2 * 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 d5666ca..315290a 100644 --- a/src/uninstall.php +++ b/src/uninstall.php @@ -16,7 +16,7 @@ * * @link https://wordpress.org/plugins/woo-retailcrm/ * - * @version 4.6.1 + * @version 4.6.2 * * @package RetailCRM */ diff --git a/tests/test-wc-retailcrm-history.php b/tests/test-wc-retailcrm-history.php index 89da0ab..2e85def 100644 --- a/tests/test-wc-retailcrm-history.php +++ b/tests/test-wc-retailcrm-history.php @@ -105,6 +105,27 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper } } + public function test_history_order_create_with_empty_address_delivery() + { + $product = WC_Helper_Product::create_simple_product(); + $order = DataHistoryRetailCrm::get_history_data_new_order($product->get_id()); + $order['history'][0]['order']['delivery']['address'] = null; + + $this->mockHistory(true, DataHistoryRetailCrm::empty_history(), $order); + + $retailcrm_history = new WC_Retailcrm_History($this->apiMock); + $retailcrm_history->getHistory(); + + $orders = wc_get_orders(['numberposts' => -1]); + $wcOrder = end($orders); + + if (!$wcOrder) { + $this->fail('$order_added is null - no orders were added after receiving history'); + } + + $this->assertNotEmpty($wcOrder->get_date_created()); + } + public function test_history_order_create_statuses() { $product = WC_Helper_Product::create_simple_product();