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();