mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-24 22:26:06 +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:
|
||||
- test
|
||||
- phpcs
|
||||
- deploy
|
||||
|
||||
before_install:
|
||||
@ -119,6 +120,10 @@ jobs:
|
||||
env: TEST_SUITE=3.0 OPENCART=3.0.3.1
|
||||
- php: 7.3
|
||||
env: TEST_SUITE=3.0 OPENCART=3.0.3.2
|
||||
- stage: phpcs
|
||||
before_script: composer install
|
||||
script: make phpcomp
|
||||
after_success: skip
|
||||
- stage: deploy
|
||||
before_script: skip
|
||||
script: make build_archive
|
||||
|
6
Makefile
6
Makefile
@ -45,3 +45,9 @@ run_test: run
|
||||
|
||||
test: robo_deploy
|
||||
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": {
|
||||
"consolidation/robo": "~1.0",
|
||||
"beyondit/opencart-test-suite": "~3.0",
|
||||
"opencart/opencart": "3.0.2.0"
|
||||
"phpcompatibility/php-compatibility": "^9.3"
|
||||
}
|
||||
}
|
||||
|
@ -278,7 +278,6 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||
'button_cancel',
|
||||
'text_notice',
|
||||
'retailcrm_title',
|
||||
'retailcrm_apiversion',
|
||||
'retailcrm_url',
|
||||
'retailcrm_apikey',
|
||||
'retailcrm_base_settings',
|
||||
@ -358,9 +357,6 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||
$key = isset($_data['saved_settings'][$this->moduleTitle . '_apikey'])
|
||||
? $_data['saved_settings'][$this->moduleTitle . '_apikey']
|
||||
: null;
|
||||
$apiVersion = isset($_data['saved_settings'][$this->moduleTitle . '_apiversion'])
|
||||
? $_data['saved_settings'][$this->moduleTitle . '_apiversion']
|
||||
: null;
|
||||
|
||||
if (!empty($url) && !empty($key)) {
|
||||
|
||||
@ -370,11 +366,8 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||
->getOrderStatuses();
|
||||
$_data['payments'] = $this->model_extension_retailcrm_references
|
||||
->getPaymentTypes();
|
||||
|
||||
if ($apiVersion == 'v5') {
|
||||
$_data['customFields'] = $this->model_extension_retailcrm_references
|
||||
->getCustomFields();
|
||||
}
|
||||
$_data['customFields'] = $this->model_extension_retailcrm_references
|
||||
->getCustomFields();
|
||||
|
||||
$_data['lenghts'] = $this->model_localisation_length_class->getLengthClasses();
|
||||
$_data['priceTypes'] = $this->model_extension_retailcrm_references
|
||||
|
@ -20,7 +20,6 @@ $_['collector_tab_text'] = 'Daemon Collector';
|
||||
$_['logs_tab_text'] = 'Logs';
|
||||
$_['collector_custom_text'] = 'Configuration of form fields';
|
||||
$_['custom_fields_tab_text'] = 'Custom fields';
|
||||
$_['retailcrm_apiversion'] = 'API Version';
|
||||
$_['retailcrm_url'] = 'URL of retailCRM';
|
||||
$_['retailcrm_apikey'] = 'API key of retailCRM';
|
||||
$_['corporate_enabled_label'] = 'Corporate customers support';
|
||||
|
@ -20,7 +20,6 @@ $_['collector_tab_text'] = 'Daemon Collector';
|
||||
$_['logs_tab_text'] = 'Registro';
|
||||
$_['collector_custom_text'] = 'Configurar campos de formulario';
|
||||
$_['custom_fields_tab_text'] = 'Campos personalizados';
|
||||
$_['retailcrm_apiversion'] = 'Versión de la API';
|
||||
$_['retailcrm_url'] = 'Dirección del retailCRM';
|
||||
$_['retailcrm_apikey'] = 'Clave de la API del retailCRM';
|
||||
$_['corporate_enabled_label'] = 'Corporate customers support';
|
||||
|
@ -20,7 +20,6 @@ $_['consultant_tab_text'] = 'Online Consultant';
|
||||
$_['logs_tab_text'] = 'Логи';
|
||||
$_['collector_custom_text'] = 'Настройка полей формы';
|
||||
$_['custom_fields_tab_text'] = 'Пользовательские поля';
|
||||
$_['retailcrm_apiversion'] = 'Версия API';
|
||||
$_['retailcrm_url'] = 'Адрес RetailCRM';
|
||||
$_['retailcrm_apikey'] = 'Api ключ RetailCRM';
|
||||
$_['corporate_enabled_label'] = 'Поддержка корпоративных клиентов';
|
||||
|
@ -60,10 +60,6 @@ class ModelExtensionRetailcrmPrices extends Model
|
||||
$prices = array();
|
||||
$site = $this->getSite($retailcrmApiClient);
|
||||
|
||||
if ($this->settings[$this->moduleTitle . '_apiversion'] == 'v3') {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($products as $product) {
|
||||
$specials = $this->model_catalog_product->getProductSpecials($product['product_id']);
|
||||
|
||||
|
@ -68,7 +68,7 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
$response = $retailcrmApiClient->ordersEdit($order);
|
||||
}
|
||||
|
||||
if ($this->settings[$this->moduleTitle . '_apiversion'] == 'v5' && $response->isSuccessful()) {
|
||||
if ($response->isSuccessful()) {
|
||||
$this->updatePayment($order_payment, $order['externalId'], $retailcrmApiClient);
|
||||
}
|
||||
}
|
||||
@ -169,16 +169,8 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
}
|
||||
|
||||
$order['createdAt'] = $order_data['date_added'];
|
||||
|
||||
if ($this->settings[$this->moduleTitle . '_apiversion'] != 'v5') {
|
||||
$order['paymentType'] = $payment_code;
|
||||
if ($couponTotal > 0) {
|
||||
$order['discount'] = $couponTotal;
|
||||
}
|
||||
} else {
|
||||
if ($couponTotal > 0) {
|
||||
$order['discountManualAmount'] = $couponTotal;
|
||||
}
|
||||
if ($couponTotal > 0) {
|
||||
$order['discountManualAmount'] = $couponTotal;
|
||||
}
|
||||
|
||||
$country = isset($order_data['shipping_country']) ? $order_data['shipping_country'] : '' ;
|
||||
@ -245,38 +237,29 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
$offerId = implode('_', $offerId);
|
||||
}
|
||||
|
||||
if ($this->settings[$this->moduleTitle . '_apiversion'] != 'v3') {
|
||||
$item = array(
|
||||
'offer' => array(
|
||||
'externalId' => !empty($offerId) ? $product['product_id'].'#'.$offerId : $product['product_id']
|
||||
),
|
||||
'productName' => $product['name'],
|
||||
'initialPrice' => $product['price'],
|
||||
'quantity' => $product['quantity']
|
||||
);
|
||||
$item = array(
|
||||
'offer' => array(
|
||||
'externalId' => !empty($offerId) ? $product['product_id'].'#'.$offerId : $product['product_id']
|
||||
),
|
||||
'productName' => $product['name'],
|
||||
'initialPrice' => $product['price'],
|
||||
'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)) {
|
||||
$customer = $this->model_account_customer->getCustomer($order_data['customer_id']);
|
||||
if (!empty($specials)) {
|
||||
$customer = $this->model_account_customer->getCustomer($order_data['customer_id']);
|
||||
|
||||
foreach ($specials as $special) {
|
||||
if (isset($customer['customer_group_id'])) {
|
||||
if ($special['customer_group_id'] == $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']];
|
||||
}
|
||||
foreach ($specials as $special) {
|
||||
if (isset($customer['customer_group_id'])) {
|
||||
if ($special['customer_group_id'] == $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']];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
|
@ -8,7 +8,7 @@
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @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
|
||||
{
|
||||
|
@ -8,7 +8,7 @@
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @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
|
||||
{
|
||||
|
@ -8,7 +8,7 @@
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @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
|
||||
{
|
||||
|
@ -8,7 +8,7 @@
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @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
|
||||
{
|
||||
|
@ -229,7 +229,7 @@ class Order {
|
||||
$product_id = $item['offer']['externalId'];
|
||||
$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']);
|
||||
$product_id = $offer[0];
|
||||
$options_from_crm = explode('_', $offer[1]);
|
||||
|
@ -18,8 +18,10 @@ class SettingsManager extends \retailcrm\Base {
|
||||
}
|
||||
|
||||
public function getSetting($key) {
|
||||
if (!empty($this->getSettings()[$this->retailcrm->getModuleTitle() . '_' . $key])) {
|
||||
return $this->getSettings()[$this->retailcrm->getModuleTitle() . '_' . $key];
|
||||
$settings = $this->getSettings();
|
||||
|
||||
if (!empty($settings[$this->retailcrm->getModuleTitle() . '_' . $key])) {
|
||||
return $settings[$this->retailcrm->getModuleTitle() . '_' . $key];
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -52,11 +52,10 @@ class Retailcrm {
|
||||
*
|
||||
* @param string $apiUrl (default = null)
|
||||
* @param string $apiKey (default = null)
|
||||
* @param string $apiVersion (default = null)
|
||||
*
|
||||
* @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')) {
|
||||
$setting = $this->model_setting_setting->getSetting($this->getModuleTitle());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user