parent
0566309c24
commit
4ea6015d74
@ -1,3 +1,6 @@
|
||||
## 2023-10-02 4.6.12
|
||||
* Added currency validation when configuring the module
|
||||
|
||||
## 2023-08-31 4.6.11
|
||||
* Added the ability to work with coupons through the CRM system
|
||||
|
||||
|
2
Makefile
2
Makefile
@ -40,7 +40,7 @@ local_test:
|
||||
run_tests:
|
||||
docker-compose --no-ansi up -d --build mysql
|
||||
docker-compose --no-ansi run --rm --no-deps app make local_test
|
||||
docker-compose stop
|
||||
docker-compose down -v
|
||||
|
||||
coverage:
|
||||
wget https://phar.phpunit.de/phpcov-2.0.2.phar && php phpcov-2.0.2.phar merge coverage/ --clover coverage.xml
|
||||
|
@ -437,4 +437,10 @@ msgid "Select warehouses to receive balances from CRM. To select several warehou
|
||||
msgstr "Selecciona los almacenes para recibir el stock desde CRM. Para seleccionar varios mantén pulsado CTRL (para Windows y Linux) o ⌘ Command (para MacOS)"
|
||||
|
||||
msgid "I agree to receive promotional newsletters"
|
||||
msgstr "Estoy de acuerdo en recibir los boletines informativos"
|
||||
msgstr "Estoy de acuerdo en recibir los boletines informativos"
|
||||
|
||||
msgid "API key with one-shop access required"
|
||||
msgstr "Se requiere clave API con acceso a una tienda"
|
||||
|
||||
msgid "The currency of the site differs from the currency of the store in CRM. For the integration to work correctly, the currencies in CRM and CMS must match"
|
||||
msgstr "La moneda del sitio web es distinto a la tienda del CRM. Para el funcionamiento correcto de la integración, las monedas del CMS y CRM deben coincid"
|
@ -447,3 +447,9 @@ msgstr "Выберите склады для получения остатков
|
||||
|
||||
msgid "I agree to receive promotional newsletters"
|
||||
msgstr "Согласен на рекламно-информационные рассылки"
|
||||
|
||||
msgid "API key with one-shop access required"
|
||||
msgstr "Требуется API ключ с доступом к одному магазину"
|
||||
|
||||
msgid "The currency of the site differs from the currency of the store in CRM. For the integration to work correctly, the currencies in CRM and CMS must match"
|
||||
msgstr "Валюта сайта отличается от валюты магазина в CRM. Для корректной работы интеграции, валюты в CRM и CMS должны совпадать"
|
||||
|
@ -72,7 +72,6 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize integration settings form fields.
|
||||
*/
|
||||
@ -98,6 +97,11 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
|
||||
];
|
||||
|
||||
if ($this->apiClient) {
|
||||
// The field is highlighted in red if the CRM site is invalid
|
||||
$this->form_fields['api_key']['class'] = $this->isValidCrmSite($this->apiClient)
|
||||
? ''
|
||||
: 'red-selected-retailcrm';
|
||||
|
||||
if (
|
||||
isset($_GET['page']) && $_GET['page'] == 'wc-settings'
|
||||
&& isset($_GET['tab']) && $_GET['tab'] == 'integration'
|
||||
@ -816,20 +820,48 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
|
||||
return $value;
|
||||
}
|
||||
|
||||
$api = new WC_Retailcrm_Proxy($this->crmUrl, $value);
|
||||
$response = $api->apiVersions();
|
||||
$isValidCrmSite = $this->isValidCrmSite(new WC_Retailcrm_Proxy($this->crmUrl, $value));
|
||||
|
||||
if (empty($response) || !$response->isSuccessful()) {
|
||||
$value = '';
|
||||
// The field is highlighted in red if the CRM site is invalid
|
||||
if ($isValidCrmSite) {
|
||||
$this->form_fields['api_key']['class'] = '';
|
||||
|
||||
WC_Admin_Settings::add_error(esc_html__('Enter the correct API key', 'retailcrm'));
|
||||
} else {
|
||||
header("Refresh:0");
|
||||
} else {
|
||||
$value = '';
|
||||
$this->form_fields['api_key']['class'] = 'red-selected-retailcrm';
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
private function isValidCrmSite($api)
|
||||
{
|
||||
$errorMessage = '';
|
||||
$isValidCrmSite = true;
|
||||
$response = $api->sitesList();
|
||||
|
||||
if (empty($response['sites']) || !$response->isSuccessful()) {
|
||||
$errorMessage = 'Enter the correct API key';
|
||||
$isValidCrmSite = false;
|
||||
} elseif (count($response['sites']) > 1) {
|
||||
$errorMessage = 'API key with one-shop access required';
|
||||
$isValidCrmSite = false;
|
||||
} else {
|
||||
$site = current($response['sites']);
|
||||
|
||||
if (get_woocommerce_currency() !== $site['currency']) {
|
||||
$errorMessage = 'The currency of the site differs from the currency of the store in CRM. For the integration to work correctly, the currencies in CRM and CMS must match';
|
||||
$isValidCrmSite = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ('' !== $errorMessage) {
|
||||
WC_Admin_Settings::add_error(esc_html__($errorMessage, 'retailcrm'));
|
||||
}
|
||||
|
||||
return $isValidCrmSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate whatsapp phone number
|
||||
|
Binary file not shown.
Binary file not shown.
@ -5,7 +5,7 @@ Tags: Интеграция, Simla.com, simla
|
||||
Requires PHP: 7.0
|
||||
Requires at least: 5.3
|
||||
Tested up to: 6.2
|
||||
Stable tag: 4.6.11
|
||||
Stable tag: 4.6.12
|
||||
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.12 =
|
||||
* Added currency validation when configuring the module
|
||||
|
||||
= 4.6.11 =
|
||||
* Added the ability to work with coupons through the CRM system
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Description: Integration plugin for WooCommerce & Simla.com
|
||||
* Author: RetailDriver LLC
|
||||
* Author URI: http://retailcrm.pro/
|
||||
* Version: 4.6.11
|
||||
* Version: 4.6.12
|
||||
* Tested up to: 6.2
|
||||
* WC requires at least: 5.4
|
||||
* WC tested up to: 7.8
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @link https://wordpress.org/plugins/woo-retailcrm/
|
||||
*
|
||||
* @version 4.6.11
|
||||
* @version 4.6.12
|
||||
*
|
||||
* @package RetailCRM
|
||||
*/
|
||||
|
@ -164,4 +164,12 @@ class DataBaseRetailCrm
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public static function getResponseSitesList()
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'sites' => ['woocommerce' => ['currency' => 'RUB']],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ class WC_Retailcrm_Base_Test extends WC_Retailcrm_Test_Case_Helper
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(
|
||||
[
|
||||
'sitesList',
|
||||
'storesList',
|
||||
'orderMethodsList',
|
||||
'deliveryTypesList',
|
||||
@ -50,6 +51,7 @@ class WC_Retailcrm_Base_Test extends WC_Retailcrm_Test_Case_Helper
|
||||
$this->setMockStatuses();
|
||||
$this->setMockCustomFields();
|
||||
$this->setMockStoresList();
|
||||
$this->setMockSitesList();
|
||||
|
||||
$_GET['page'] = 'wc-settings';
|
||||
$_GET['tab'] = 'integration';
|
||||
@ -272,7 +274,6 @@ class WC_Retailcrm_Base_Test extends WC_Retailcrm_Test_Case_Helper
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
|
||||
public function test_initialize_whatsapp()
|
||||
{
|
||||
ob_start();
|
||||
@ -426,6 +427,19 @@ class WC_Retailcrm_Base_Test extends WC_Retailcrm_Test_Case_Helper
|
||||
$this->responseMockStoresList->setResponse(DataBaseRetailCrm::getResponseStoreList());
|
||||
$this->setMockResponse($this->apiMock, 'storesList', $this->responseMockStoresList);
|
||||
}
|
||||
private function setMockSitesList()
|
||||
{
|
||||
$this->responseMockStoresList = $this
|
||||
->getMockBuilder('\WC_Retailcrm_Response_Helper')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['isSuccessful'])
|
||||
->getMock();
|
||||
|
||||
$this->setMockResponse($this->responseMockStoresList, 'isSuccessful', true);
|
||||
|
||||
$this->responseMockStoresList->setResponse(DataBaseRetailCrm::getResponseSitesList());
|
||||
$this->setMockResponse($this->apiMock, 'storesList', $this->responseMockStoresList);
|
||||
}
|
||||
|
||||
private function setMockOrderMethods()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user