Compare commits
4 commits
Author | SHA1 | Date | |
---|---|---|---|
|
4363cccc40 | ||
|
3610cec728 | ||
|
bce545979c | ||
|
cd57de01e6 |
11 changed files with 110 additions and 28 deletions
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -1,3 +1,15 @@
|
||||||
|
## 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
|
||||||
|
* Added additional parameters to GET requests
|
||||||
|
|
||||||
## 2025-01-21 4.8.17
|
## 2025-01-21 4.8.17
|
||||||
* Fix deploy
|
* Fix deploy
|
||||||
|
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
4.8.17
|
4.8.21
|
||||||
|
|
|
@ -77,9 +77,10 @@ class WC_Retailcrm_Request
|
||||||
'cms_version' => function_exists('get_bloginfo') ? get_bloginfo('version') : '',
|
'cms_version' => function_exists('get_bloginfo') ? get_bloginfo('version') : '',
|
||||||
'woo_version' => WC()->version ?? '',
|
'woo_version' => WC()->version ?? '',
|
||||||
'php_version' => function_exists('phpversion') ? phpversion() : '',
|
'php_version' => function_exists('phpversion') ? phpversion() : '',
|
||||||
'module_version' => WC_Integration_Retailcrm::MODULE_VERSION,
|
'module_version' => WC_Integration_Retailcrm::MODULE_VERSION,
|
||||||
|
'ga_option_is_active' => getOptionByCode('ua') === WC_Retailcrm_Abstracts_Settings::YES,
|
||||||
])
|
])
|
||||||
: $parameters = array_merge($this->defaultParameters, $parameters);
|
: array_merge($this->defaultParameters, $parameters);
|
||||||
|
|
||||||
$url = $this->url . $path;
|
$url = $this->url . $path;
|
||||||
|
|
||||||
|
|
|
@ -120,9 +120,8 @@ 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)
|
public function offsetSet($offset, $value): void
|
||||||
{
|
{
|
||||||
throw new \BadMethodCallException('This activity not allowed');
|
throw new \BadMethodCallException('This activity not allowed');
|
||||||
}
|
}
|
||||||
|
@ -133,9 +132,8 @@ class WC_Retailcrm_Response implements \ArrayAccess
|
||||||
* @param mixed $offset offset
|
* @param mixed $offset offset
|
||||||
*
|
*
|
||||||
* @throws \BadMethodCallException
|
* @throws \BadMethodCallException
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function offsetUnset($offset)
|
public function offsetUnset($offset): void
|
||||||
{
|
{
|
||||||
throw new \BadMethodCallException('This call not allowed');
|
throw new \BadMethodCallException('This call not allowed');
|
||||||
}
|
}
|
||||||
|
@ -145,9 +143,8 @@ class WC_Retailcrm_Response implements \ArrayAccess
|
||||||
*
|
*
|
||||||
* @param mixed $offset offset
|
* @param mixed $offset offset
|
||||||
*
|
*
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function offsetExists($offset)
|
public function offsetExists($offset): bool
|
||||||
{
|
{
|
||||||
return isset($this->response[$offset]);
|
return isset($this->response[$offset]);
|
||||||
}
|
}
|
||||||
|
@ -156,10 +153,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
|
||||||
*
|
*
|
||||||
* @return mixed
|
* TODO PHP < 8.0 не поддерживает тип mixed. Оператор | для перечисления типов также не поддерживается.
|
||||||
*/
|
*/
|
||||||
public function offsetGet($offset)
|
public function offsetGet($offset)
|
||||||
{
|
{
|
||||||
|
|
|
@ -602,6 +602,32 @@ 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
|
||||||
*
|
*
|
||||||
|
|
|
@ -83,14 +83,11 @@ 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);
|
||||||
|
@ -98,14 +95,40 @@ if (class_exists('WC_Retailcrm_Uploader') === false) {
|
||||||
$orderIds = $ids;
|
$orderIds = $ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($orderIds !== []) {
|
if ($orderIds === []) {
|
||||||
foreach ($orderIds as $orderId) {
|
return null;
|
||||||
$errorMessage = $this->orders->orderCreate($orderId);
|
}
|
||||||
|
|
||||||
if (is_string($errorMessage)) {
|
WC_Retailcrm_Logger::info(__METHOD__, 'Archive order IDs: ' . implode(', ', $ids));
|
||||||
$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);
|
||||||
|
@ -225,7 +248,7 @@ if (class_exists('WC_Retailcrm_Uploader') === false) {
|
||||||
*/
|
*/
|
||||||
private function logOrdersUploadErrors($errors)
|
private function logOrdersUploadErrors($errors)
|
||||||
{
|
{
|
||||||
if (empty($errors) === true) {
|
if ($errors === []) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,3 +207,8 @@ function isCorporateOrder($wcCustomer, $wcOrder)
|
||||||
{
|
{
|
||||||
return !empty($wcCustomer->get_billing_company()) || !empty($wcOrder->get_billing_company());
|
return !empty($wcCustomer->get_billing_company()) || !empty($wcOrder->get_billing_company());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getOptionByCode($optionName)
|
||||||
|
{
|
||||||
|
return get_option(WC_Retailcrm_Base::$option_key)[$optionName] ?? null;
|
||||||
|
}
|
||||||
|
|
|
@ -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.17
|
Stable tag: 4.8.21
|
||||||
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,6 +82,18 @@ 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 =
|
||||||
|
* Added additional parameters to GET requests
|
||||||
|
|
||||||
= 4.8.17 =
|
= 4.8.17 =
|
||||||
* Fix deploy
|
* Fix deploy
|
||||||
|
|
||||||
|
|
|
@ -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.17
|
* Version: 4.8.21
|
||||||
* 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.17';
|
const MODULE_VERSION = '4.8.21';
|
||||||
|
|
||||||
private static $instance;
|
private static $instance;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @link https://wordpress.org/plugins/woo-retailcrm/
|
* @link https://wordpress.org/plugins/woo-retailcrm/
|
||||||
*
|
*
|
||||||
* @version 4.8.17
|
* @version 4.8.21
|
||||||
*
|
*
|
||||||
* @package RetailCRM
|
* @package RetailCRM
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -36,7 +36,8 @@ class WC_Retailcrm_Uploader_Test extends WC_Retailcrm_Test_Case_Helper
|
||||||
'getCountOrders',
|
'getCountOrders',
|
||||||
'customersGet',
|
'customersGet',
|
||||||
'customersList',
|
'customersList',
|
||||||
'ordersCreate'
|
'ordersCreate',
|
||||||
|
'ordersUpload',
|
||||||
))
|
))
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
|
@ -96,10 +97,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()
|
public function test_upload_selected_orders($retailcrm)
|
||||||
{
|
{
|
||||||
$_GET['order_ids_retailcrm'] = '123, 345, 456';
|
$_GET['order_ids_retailcrm'] = '123, 345, 456';
|
||||||
$retailcrm_uploader = $this->getRetailcrmUploader($this->apiMock);
|
$retailcrm_uploader = $this->getRetailcrmUploader($retailcrm);
|
||||||
$uploadSelectedOrders = $retailcrm_uploader->uploadSelectedOrders();
|
$uploadSelectedOrders = $retailcrm_uploader->uploadSelectedOrders();
|
||||||
|
|
||||||
$this->assertEquals(null, $uploadSelectedOrders);
|
$this->assertEquals(null, $uploadSelectedOrders);
|
||||||
|
@ -123,6 +124,11 @@ 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(
|
||||||
|
|
Loading…
Add table
Reference in a new issue