mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-28 16:16:05 +03:00
cleared api version detecting (#198)
* cleared api version detecting * phpcs stage
This commit is contained in:
parent
769f35f379
commit
579150ea08
@ -19,6 +19,7 @@ env:
|
|||||||
|
|
||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
|
- phpcs
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
@ -119,6 +120,10 @@ jobs:
|
|||||||
env: TEST_SUITE=3.0 OPENCART=3.0.3.1
|
env: TEST_SUITE=3.0 OPENCART=3.0.3.1
|
||||||
- php: 7.3
|
- php: 7.3
|
||||||
env: TEST_SUITE=3.0 OPENCART=3.0.3.2
|
env: TEST_SUITE=3.0 OPENCART=3.0.3.2
|
||||||
|
- stage: phpcs
|
||||||
|
before_script: composer install
|
||||||
|
script: make phpcomp
|
||||||
|
after_success: skip
|
||||||
- stage: deploy
|
- stage: deploy
|
||||||
before_script: skip
|
before_script: skip
|
||||||
script: make build_archive
|
script: make build_archive
|
||||||
|
6
Makefile
6
Makefile
@ -45,3 +45,9 @@ run_test: run
|
|||||||
|
|
||||||
test: robo_deploy
|
test: robo_deploy
|
||||||
composer test
|
composer test
|
||||||
|
|
||||||
|
phpcs-config:
|
||||||
|
bin/phpcs --config-set installed_paths vendor/phpcompatibility/php-compatibility
|
||||||
|
|
||||||
|
phpcomp: phpcs-config
|
||||||
|
@bin/phpcs -s -p ./src --standard=PHPCompatibility --runtime-set testVersion 5.4-7.3
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"consolidation/robo": "~1.0",
|
"consolidation/robo": "~1.0",
|
||||||
"beyondit/opencart-test-suite": "~3.0",
|
"phpcompatibility/php-compatibility": "^9.3"
|
||||||
"opencart/opencart": "3.0.2.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,6 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
|||||||
'button_cancel',
|
'button_cancel',
|
||||||
'text_notice',
|
'text_notice',
|
||||||
'retailcrm_title',
|
'retailcrm_title',
|
||||||
'retailcrm_apiversion',
|
|
||||||
'retailcrm_url',
|
'retailcrm_url',
|
||||||
'retailcrm_apikey',
|
'retailcrm_apikey',
|
||||||
'retailcrm_base_settings',
|
'retailcrm_base_settings',
|
||||||
@ -358,9 +357,6 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
|||||||
$key = isset($_data['saved_settings'][$this->moduleTitle . '_apikey'])
|
$key = isset($_data['saved_settings'][$this->moduleTitle . '_apikey'])
|
||||||
? $_data['saved_settings'][$this->moduleTitle . '_apikey']
|
? $_data['saved_settings'][$this->moduleTitle . '_apikey']
|
||||||
: null;
|
: null;
|
||||||
$apiVersion = isset($_data['saved_settings'][$this->moduleTitle . '_apiversion'])
|
|
||||||
? $_data['saved_settings'][$this->moduleTitle . '_apiversion']
|
|
||||||
: null;
|
|
||||||
|
|
||||||
if (!empty($url) && !empty($key)) {
|
if (!empty($url) && !empty($key)) {
|
||||||
|
|
||||||
@ -370,11 +366,8 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
|||||||
->getOrderStatuses();
|
->getOrderStatuses();
|
||||||
$_data['payments'] = $this->model_extension_retailcrm_references
|
$_data['payments'] = $this->model_extension_retailcrm_references
|
||||||
->getPaymentTypes();
|
->getPaymentTypes();
|
||||||
|
$_data['customFields'] = $this->model_extension_retailcrm_references
|
||||||
if ($apiVersion == 'v5') {
|
->getCustomFields();
|
||||||
$_data['customFields'] = $this->model_extension_retailcrm_references
|
|
||||||
->getCustomFields();
|
|
||||||
}
|
|
||||||
|
|
||||||
$_data['lenghts'] = $this->model_localisation_length_class->getLengthClasses();
|
$_data['lenghts'] = $this->model_localisation_length_class->getLengthClasses();
|
||||||
$_data['priceTypes'] = $this->model_extension_retailcrm_references
|
$_data['priceTypes'] = $this->model_extension_retailcrm_references
|
||||||
|
@ -20,7 +20,6 @@ $_['collector_tab_text'] = 'Daemon Collector';
|
|||||||
$_['logs_tab_text'] = 'Logs';
|
$_['logs_tab_text'] = 'Logs';
|
||||||
$_['collector_custom_text'] = 'Configuration of form fields';
|
$_['collector_custom_text'] = 'Configuration of form fields';
|
||||||
$_['custom_fields_tab_text'] = 'Custom fields';
|
$_['custom_fields_tab_text'] = 'Custom fields';
|
||||||
$_['retailcrm_apiversion'] = 'API Version';
|
|
||||||
$_['retailcrm_url'] = 'URL of retailCRM';
|
$_['retailcrm_url'] = 'URL of retailCRM';
|
||||||
$_['retailcrm_apikey'] = 'API key of retailCRM';
|
$_['retailcrm_apikey'] = 'API key of retailCRM';
|
||||||
$_['corporate_enabled_label'] = 'Corporate customers support';
|
$_['corporate_enabled_label'] = 'Corporate customers support';
|
||||||
|
@ -20,7 +20,6 @@ $_['collector_tab_text'] = 'Daemon Collector';
|
|||||||
$_['logs_tab_text'] = 'Registro';
|
$_['logs_tab_text'] = 'Registro';
|
||||||
$_['collector_custom_text'] = 'Configurar campos de formulario';
|
$_['collector_custom_text'] = 'Configurar campos de formulario';
|
||||||
$_['custom_fields_tab_text'] = 'Campos personalizados';
|
$_['custom_fields_tab_text'] = 'Campos personalizados';
|
||||||
$_['retailcrm_apiversion'] = 'Versión de la API';
|
|
||||||
$_['retailcrm_url'] = 'Dirección del retailCRM';
|
$_['retailcrm_url'] = 'Dirección del retailCRM';
|
||||||
$_['retailcrm_apikey'] = 'Clave de la API del retailCRM';
|
$_['retailcrm_apikey'] = 'Clave de la API del retailCRM';
|
||||||
$_['corporate_enabled_label'] = 'Corporate customers support';
|
$_['corporate_enabled_label'] = 'Corporate customers support';
|
||||||
|
@ -20,7 +20,6 @@ $_['consultant_tab_text'] = 'Online Consultant';
|
|||||||
$_['logs_tab_text'] = 'Логи';
|
$_['logs_tab_text'] = 'Логи';
|
||||||
$_['collector_custom_text'] = 'Настройка полей формы';
|
$_['collector_custom_text'] = 'Настройка полей формы';
|
||||||
$_['custom_fields_tab_text'] = 'Пользовательские поля';
|
$_['custom_fields_tab_text'] = 'Пользовательские поля';
|
||||||
$_['retailcrm_apiversion'] = 'Версия API';
|
|
||||||
$_['retailcrm_url'] = 'Адрес RetailCRM';
|
$_['retailcrm_url'] = 'Адрес RetailCRM';
|
||||||
$_['retailcrm_apikey'] = 'Api ключ RetailCRM';
|
$_['retailcrm_apikey'] = 'Api ключ RetailCRM';
|
||||||
$_['corporate_enabled_label'] = 'Поддержка корпоративных клиентов';
|
$_['corporate_enabled_label'] = 'Поддержка корпоративных клиентов';
|
||||||
|
@ -60,10 +60,6 @@ class ModelExtensionRetailcrmPrices extends Model
|
|||||||
$prices = array();
|
$prices = array();
|
||||||
$site = $this->getSite($retailcrmApiClient);
|
$site = $this->getSite($retailcrmApiClient);
|
||||||
|
|
||||||
if ($this->settings[$this->moduleTitle . '_apiversion'] == 'v3') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($products as $product) {
|
foreach ($products as $product) {
|
||||||
$specials = $this->model_catalog_product->getProductSpecials($product['product_id']);
|
$specials = $this->model_catalog_product->getProductSpecials($product['product_id']);
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class ModelExtensionRetailcrmOrder extends Model {
|
|||||||
$response = $retailcrmApiClient->ordersEdit($order);
|
$response = $retailcrmApiClient->ordersEdit($order);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->settings[$this->moduleTitle . '_apiversion'] == 'v5' && $response->isSuccessful()) {
|
if ($response->isSuccessful()) {
|
||||||
$this->updatePayment($order_payment, $order['externalId'], $retailcrmApiClient);
|
$this->updatePayment($order_payment, $order['externalId'], $retailcrmApiClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,16 +169,8 @@ class ModelExtensionRetailcrmOrder extends Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$order['createdAt'] = $order_data['date_added'];
|
$order['createdAt'] = $order_data['date_added'];
|
||||||
|
if ($couponTotal > 0) {
|
||||||
if ($this->settings[$this->moduleTitle . '_apiversion'] != 'v5') {
|
$order['discountManualAmount'] = $couponTotal;
|
||||||
$order['paymentType'] = $payment_code;
|
|
||||||
if ($couponTotal > 0) {
|
|
||||||
$order['discount'] = $couponTotal;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($couponTotal > 0) {
|
|
||||||
$order['discountManualAmount'] = $couponTotal;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$country = isset($order_data['shipping_country']) ? $order_data['shipping_country'] : '' ;
|
$country = isset($order_data['shipping_country']) ? $order_data['shipping_country'] : '' ;
|
||||||
@ -245,38 +237,29 @@ class ModelExtensionRetailcrmOrder extends Model {
|
|||||||
$offerId = implode('_', $offerId);
|
$offerId = implode('_', $offerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->settings[$this->moduleTitle . '_apiversion'] != 'v3') {
|
$item = array(
|
||||||
$item = array(
|
'offer' => array(
|
||||||
'offer' => array(
|
'externalId' => !empty($offerId) ? $product['product_id'].'#'.$offerId : $product['product_id']
|
||||||
'externalId' => !empty($offerId) ? $product['product_id'].'#'.$offerId : $product['product_id']
|
),
|
||||||
),
|
'productName' => $product['name'],
|
||||||
'productName' => $product['name'],
|
'initialPrice' => $product['price'],
|
||||||
'initialPrice' => $product['price'],
|
'quantity' => $product['quantity']
|
||||||
'quantity' => $product['quantity']
|
);
|
||||||
);
|
|
||||||
|
|
||||||
$specials = $this->model_extension_retailcrm_product->getProductSpecials($product['product_id']);
|
$specials = $this->model_extension_retailcrm_product->getProductSpecials($product['product_id']);
|
||||||
|
|
||||||
if (!empty($specials)) {
|
if (!empty($specials)) {
|
||||||
$customer = $this->model_account_customer->getCustomer($order_data['customer_id']);
|
$customer = $this->model_account_customer->getCustomer($order_data['customer_id']);
|
||||||
|
|
||||||
foreach ($specials as $special) {
|
foreach ($specials as $special) {
|
||||||
if (isset($customer['customer_group_id'])) {
|
if (isset($customer['customer_group_id'])) {
|
||||||
if ($special['customer_group_id'] == $customer['customer_group_id']) {
|
if ($special['customer_group_id'] == $customer['customer_group_id']) {
|
||||||
if ($this->settings[$this->moduleTitle . '_special_' . $customer['customer_group_id']]) {
|
if ($this->settings[$this->moduleTitle . '_special_' . $customer['customer_group_id']]) {
|
||||||
$item['priceType']['code'] = $this->settings[$this->moduleTitle . '_special_' . $customer['customer_group_id']];
|
$item['priceType']['code'] = $this->settings[$this->moduleTitle . '_special_' . $customer['customer_group_id']];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$item = array(
|
|
||||||
'productName' => $product['name'],
|
|
||||||
'initialPrice' => $product['price'],
|
|
||||||
'quantity' => $product['quantity'],
|
|
||||||
'productId' => !empty($offerId) ? $product['product_id'].'#'.$offerId : $product['product_id']
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($properties)) $item['properties'] = $properties;
|
if (isset($properties)) $item['properties'] = $properties;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* @package RetailCrm
|
* @package RetailCrm
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||||
*/
|
*/
|
||||||
class CurlException extends RuntimeException
|
class CurlException extends RuntimeException
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* @package RetailCrm
|
* @package RetailCrm
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||||
*/
|
*/
|
||||||
class InvalidJsonException extends DomainException
|
class InvalidJsonException extends DomainException
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* @package RetailCrm
|
* @package RetailCrm
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||||
*/
|
*/
|
||||||
class RetailcrmApiResponse implements ArrayAccess
|
class RetailcrmApiResponse implements ArrayAccess
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* @package RetailCrm
|
* @package RetailCrm
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||||
*/
|
*/
|
||||||
class RetailcrmHttpClient
|
class RetailcrmHttpClient
|
||||||
{
|
{
|
||||||
|
@ -229,7 +229,7 @@ class Order {
|
|||||||
$product_id = $item['offer']['externalId'];
|
$product_id = $item['offer']['externalId'];
|
||||||
$options = array();
|
$options = array();
|
||||||
|
|
||||||
if (mb_strpos($item['offer']['externalId'], '#') > 1) {
|
if (mb_strpos($item['offer']['externalId'], '#', 0, mb_internal_encoding()) > 1) {
|
||||||
$offer = explode('#', $item['offer']['externalId']);
|
$offer = explode('#', $item['offer']['externalId']);
|
||||||
$product_id = $offer[0];
|
$product_id = $offer[0];
|
||||||
$options_from_crm = explode('_', $offer[1]);
|
$options_from_crm = explode('_', $offer[1]);
|
||||||
|
@ -18,8 +18,10 @@ class SettingsManager extends \retailcrm\Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSetting($key) {
|
public function getSetting($key) {
|
||||||
if (!empty($this->getSettings()[$this->retailcrm->getModuleTitle() . '_' . $key])) {
|
$settings = $this->getSettings();
|
||||||
return $this->getSettings()[$this->retailcrm->getModuleTitle() . '_' . $key];
|
|
||||||
|
if (!empty($settings[$this->retailcrm->getModuleTitle() . '_' . $key])) {
|
||||||
|
return $settings[$this->retailcrm->getModuleTitle() . '_' . $key];
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -52,11 +52,10 @@ class Retailcrm {
|
|||||||
*
|
*
|
||||||
* @param string $apiUrl (default = null)
|
* @param string $apiUrl (default = null)
|
||||||
* @param string $apiKey (default = null)
|
* @param string $apiKey (default = null)
|
||||||
* @param string $apiVersion (default = null)
|
|
||||||
*
|
*
|
||||||
* @return mixed object | boolean
|
* @return mixed object | boolean
|
||||||
*/
|
*/
|
||||||
public function getApiClient($apiUrl = null, $apiKey = null, $apiVersion = null) {
|
public function getApiClient($apiUrl = null, $apiKey = null) {
|
||||||
if (!$this->registry->has('RetailcrmProxy')) {
|
if (!$this->registry->has('RetailcrmProxy')) {
|
||||||
$setting = $this->model_setting_setting->getSetting($this->getModuleTitle());
|
$setting = $this->model_setting_setting->getSetting($this->getModuleTitle());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user