1
0
mirror of synced 2025-02-21 01:13:13 +03:00

ref #88866 Доработан метод получения адреса заказа по истории (#303)

This commit is contained in:
Kocmonavtik 2023-05-17 15:33:12 +03:00 committed by GitHub
parent 9a533b97dd
commit a84b7261d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 39 additions and 6 deletions

View File

@ -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

View File

@ -1 +1 @@
4.6.1
4.6.2

View File

@ -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;

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.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

View File

@ -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

View File

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

View File

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