1
0
Fork 0
mirror of synced 2025-04-11 05:00:54 +00:00

Compare commits

..

No commits in common. "master" and "v4.8.18" have entirely different histories.

9 changed files with 26 additions and 96 deletions

View file

@ -1,12 +1,3 @@
## 2025-02-19 4.8.21
* Fix version of module
## 2025-02-18 4.8.20
* Add returned types for methods offsetExists, offsetSet, offsetUnset in WC_Retailcrm_Response
## 2025-02-04 4.8.19
* Optimization of order unloading
## 2025-02-03 4.8.18 ## 2025-02-03 4.8.18
* Added additional parameters to GET requests * Added additional parameters to GET requests

View file

@ -1 +1 @@
4.8.21 4.8.18

View file

@ -120,8 +120,9 @@ class WC_Retailcrm_Response implements \ArrayAccess
* @param mixed $value value * @param mixed $value value
* *
* @throws \BadMethodCallException * @throws \BadMethodCallException
* @return void
*/ */
public function offsetSet($offset, $value): void public function offsetSet($offset, $value)
{ {
throw new \BadMethodCallException('This activity not allowed'); throw new \BadMethodCallException('This activity not allowed');
} }
@ -132,8 +133,9 @@ class WC_Retailcrm_Response implements \ArrayAccess
* @param mixed $offset offset * @param mixed $offset offset
* *
* @throws \BadMethodCallException * @throws \BadMethodCallException
* @return void
*/ */
public function offsetUnset($offset): void public function offsetUnset($offset)
{ {
throw new \BadMethodCallException('This call not allowed'); throw new \BadMethodCallException('This call not allowed');
} }
@ -143,8 +145,9 @@ class WC_Retailcrm_Response implements \ArrayAccess
* *
* @param mixed $offset offset * @param mixed $offset offset
* *
* @return bool
*/ */
public function offsetExists($offset): bool public function offsetExists($offset)
{ {
return isset($this->response[$offset]); return isset($this->response[$offset]);
} }
@ -153,10 +156,10 @@ class WC_Retailcrm_Response implements \ArrayAccess
* Get offset * Get offset
* *
* @param mixed $offset offset * @param mixed $offset offset
* @return mixed *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* *
* TODO PHP < 8.0 не поддерживает тип mixed. Оператор | для перечисления типов также не поддерживается. * @return mixed
*/ */
public function offsetGet($offset) public function offsetGet($offset)
{ {

View file

@ -602,32 +602,6 @@ if (!class_exists('WC_Retailcrm_Orders')) :
); );
} }
public function processOrderForUpload($orderIds)
{
$ordersForUpload = [];
$errorOrders = [];
foreach ($orderIds as $orderId) {
try {
$this->order = [];
$this->processOrder(wc_get_order($orderId));
if ($this->order === []) {
throw new \RuntimeException(sprintf('Order %s is not uploaded', $orderId));
}
$ordersForUpload[] = $this->order;
} catch (Throwable $exception) {
$errorOrders[$orderId] = sprintf(
'Exception for Order [%s]: %s. Trace: %s',
$orderId, $exception->getMessage(), $exception->getTraceAsString()
);
}
}
return [$ordersForUpload, $errorOrders];
}
/** /**
* Send payment in CRM * Send payment in CRM
* *

View file

@ -83,11 +83,14 @@ if (class_exists('WC_Retailcrm_Uploader') === false) {
*/ */
public function uploadArchiveOrders(?int $page, array $ids = []) public function uploadArchiveOrders(?int $page, array $ids = [])
{ {
WC_Retailcrm_Logger::info(__METHOD__, 'Archive order IDs: ' . implode(', ', $ids));
if (!$this->retailcrm instanceof WC_Retailcrm_Proxy) { if (!$this->retailcrm instanceof WC_Retailcrm_Proxy) {
return null; return null;
} }
$orderIds = []; $orderIds = [];
$uploadErrors = [];
if (null !== $page) { if (null !== $page) {
$orderIds = $this->getCmsOrders($page); $orderIds = $this->getCmsOrders($page);
@ -95,40 +98,14 @@ if (class_exists('WC_Retailcrm_Uploader') === false) {
$orderIds = $ids; $orderIds = $ids;
} }
if ($orderIds === []) { if ($orderIds !== []) {
return null; foreach ($orderIds as $orderId) {
} $errorMessage = $this->orders->orderCreate($orderId);
WC_Retailcrm_Logger::info(__METHOD__, 'Archive order IDs: ' . implode(', ', $ids)); if (is_string($errorMessage)) {
$uploadErrors[$orderId] = $errorMessage;
[$ordersForUpload, $uploadErrors] = $this->orders->processOrderForUpload($orderIds); }
try {
$response = $this->retailcrm->ordersUpload($ordersForUpload);
if (!$response->isSuccessful()) {
throw new RuntimeException(
sprintf(
'Failure to upload orders: %s. Status code: %s',
$response->getErrorString(),
$response->getStatusCode()
)
);
} }
} catch (Exception $exception) {
WC_Retailcrm_Logger::error(
__METHOD__,
sprintf("Error while uploading orders: %s", $exception->getMessage())
);
return null;
}
/** WP version >= 6 */
if (function_exists('wp_cache_flush_runtime')) {
wp_cache_flush_runtime();
} else {
wp_cache_flush();
} }
$this->logOrdersUploadErrors($uploadErrors); $this->logOrdersUploadErrors($uploadErrors);
@ -248,7 +225,7 @@ if (class_exists('WC_Retailcrm_Uploader') === false) {
*/ */
private function logOrdersUploadErrors($errors) private function logOrdersUploadErrors($errors)
{ {
if ($errors === []) { if (empty($errors) === true) {
return; return;
} }

View file

@ -5,7 +5,7 @@ Tags: Интеграция, Simla.com, simla
Requires PHP: 7.1 Requires PHP: 7.1
Requires at least: 5.3 Requires at least: 5.3
Tested up to: 6.5 Tested up to: 6.5
Stable tag: 4.8.21 Stable tag: 4.8.18
License: GPLv1 or later License: GPLv1 or later
License URI: http://www.gnu.org/licenses/gpl-1.0.html License URI: http://www.gnu.org/licenses/gpl-1.0.html
@ -82,15 +82,6 @@ Asegúrate de tener una clave API específica para cada tienda. Las siguientes i
== Changelog == == Changelog ==
= 4.8.21 =
* Fix version of module
= 4.8.20 =
* Add returned types for methods offsetExists, offsetSet, offsetUnset in WC_Retailcrm_Response
= 4.8.19 =
* Optimization of order unloading
= 4.8.18 = = 4.8.18 =
* Added additional parameters to GET requests * Added additional parameters to GET requests

View file

@ -5,7 +5,7 @@
* Description: Integration plugin for WooCommerce & Simla.com * Description: Integration plugin for WooCommerce & Simla.com
* Author: RetailDriver LLC * Author: RetailDriver LLC
* Author URI: http://retailcrm.pro/ * Author URI: http://retailcrm.pro/
* Version: 4.8.21 * Version: 4.8.18
* Tested up to: 6.5 * Tested up to: 6.5
* Requires Plugins: woocommerce * Requires Plugins: woocommerce
* WC requires at least: 5.4 * WC requires at least: 5.4
@ -27,7 +27,7 @@ if (!class_exists( 'WC_Integration_Retailcrm')) :
class WC_Integration_Retailcrm { class WC_Integration_Retailcrm {
const WOOCOMMERCE_SLUG = 'woocommerce'; const WOOCOMMERCE_SLUG = 'woocommerce';
const WOOCOMMERCE_PLUGIN_PATH = 'woocommerce/woocommerce.php'; const WOOCOMMERCE_PLUGIN_PATH = 'woocommerce/woocommerce.php';
const MODULE_VERSION = '4.8.21'; const MODULE_VERSION = '4.8.18';
private static $instance; private static $instance;

View file

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

View file

@ -36,8 +36,7 @@ class WC_Retailcrm_Uploader_Test extends WC_Retailcrm_Test_Case_Helper
'getCountOrders', 'getCountOrders',
'customersGet', 'customersGet',
'customersList', 'customersList',
'ordersCreate', 'ordersCreate'
'ordersUpload',
)) ))
->getMock(); ->getMock();
@ -97,10 +96,10 @@ class WC_Retailcrm_Uploader_Test extends WC_Retailcrm_Test_Case_Helper
* @param $retailcrm * @param $retailcrm
* @dataProvider dataProviderApiClient * @dataProvider dataProviderApiClient
*/ */
public function test_upload_selected_orders($retailcrm) public function test_upload_selected_orders()
{ {
$_GET['order_ids_retailcrm'] = '123, 345, 456'; $_GET['order_ids_retailcrm'] = '123, 345, 456';
$retailcrm_uploader = $this->getRetailcrmUploader($retailcrm); $retailcrm_uploader = $this->getRetailcrmUploader($this->apiMock);
$uploadSelectedOrders = $retailcrm_uploader->uploadSelectedOrders(); $uploadSelectedOrders = $retailcrm_uploader->uploadSelectedOrders();
$this->assertEquals(null, $uploadSelectedOrders); $this->assertEquals(null, $uploadSelectedOrders);
@ -124,11 +123,6 @@ class WC_Retailcrm_Uploader_Test extends WC_Retailcrm_Test_Case_Helper
public function dataProviderApiClient() public function dataProviderApiClient()
{ {
$this->setUp(); $this->setUp();
$this->apiMock
->expects($this->any())
->method('ordersUpload')
->willReturn(new WC_Retailcrm_Response(200, ''))
;
return array( return array(
array( array(