Compare commits
No commits in common. "master" and "v4.8.16" have entirely different histories.
14 changed files with 370 additions and 460 deletions
15
CHANGELOG.md
15
CHANGELOG.md
|
@ -1,18 +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
|
|
||||||
* Added additional parameters to GET requests
|
|
||||||
|
|
||||||
## 2025-01-21 4.8.17
|
|
||||||
* Fix deploy
|
|
||||||
|
|
||||||
## 2025-01-13 4.8.16
|
## 2025-01-13 4.8.16
|
||||||
* Fix tests svn error
|
* Fix tests svn error
|
||||||
|
|
||||||
|
|
3
Makefile
3
Makefile
|
@ -5,8 +5,7 @@ ARCHIVE_NAME = '/tmp/retailcrm-'$(VERSION)'.zip'
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
|
|
||||||
svn_clone:
|
svn_clone:
|
||||||
sudo apt install subversion
|
mkdir /tmp/svn_plugin_dir
|
||||||
mkdir -p /tmp/svn_plugin_dir
|
|
||||||
svn co $(SVNREPOURL) /tmp/svn_plugin_dir --no-auth-cache
|
svn co $(SVNREPOURL) /tmp/svn_plugin_dir --no-auth-cache
|
||||||
|
|
||||||
svn_push: /tmp/svn_plugin_dir
|
svn_push: /tmp/svn_plugin_dir
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
4.8.21
|
4.8.16
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"ext-mbstring": "*",
|
"ext-mbstring": "*",
|
||||||
"phpunit/phpunit": "7.*",
|
"phpunit/phpunit": "6.*",
|
||||||
"yoast/phpunit-polyfills": "1.x-dev"
|
"yoast/phpunit-polyfills": "1.x-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
681
composer.lock
generated
681
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -77,10 +77,9 @@ 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,
|
|
||||||
])
|
])
|
||||||
: array_merge($this->defaultParameters, $parameters);
|
: $parameters = array_merge($this->defaultParameters, $parameters);
|
||||||
|
|
||||||
$url = $this->url . $path;
|
$url = $this->url . $path;
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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
|
||||||
*
|
*
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,8 +207,3 @@ 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.21
|
Stable tag: 4.8.16
|
||||||
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,21 +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 =
|
|
||||||
* Added additional parameters to GET requests
|
|
||||||
|
|
||||||
= 4.8.17 =
|
|
||||||
* Fix deploy
|
|
||||||
|
|
||||||
= 4.8.16 =
|
= 4.8.16 =
|
||||||
* Fix tests svn error
|
* Fix tests svn error
|
||||||
|
|
||||||
|
|
|
@ -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.16
|
||||||
* 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.16';
|
||||||
|
|
||||||
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.21
|
* @version 4.8.16
|
||||||
*
|
*
|
||||||
* @package RetailCRM
|
* @package RetailCRM
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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(
|
||||||
|
|
Loading…
Add table
Reference in a new issue