1
0
mirror of synced 2025-01-18 08:51:41 +03:00

ref #90086 Types of deliveries and payments are displayed only for available stores

This commit is contained in:
Uryvskiy Dima 2023-05-29 18:46:09 +03:00
parent a84b7261d2
commit a2980469e1
8 changed files with 76 additions and 25 deletions

View File

@ -1,3 +1,6 @@
## 2022-05-29 4.6.3
* Types of deliveries and payments are displayed only for available stores
## 2022-05-17 4.6.2
* Modified method getting an address by history

View File

@ -1 +1 @@
4.6.2
4.6.3

View File

@ -188,19 +188,30 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
];
}
/**
* Shipping options
*/
$shipping_option_list = [];
$retailcrm_shipping_list = $this->apiClient->deliveryTypesList();
$crmSite = $this->apiClient->getSingleSiteForKey();
if (!empty($retailcrm_shipping_list) && $retailcrm_shipping_list->isSuccessful()) {
foreach ($retailcrm_shipping_list['deliveryTypes'] as $retailcrm_shipping_type) {
if ($retailcrm_shipping_type['active'] == false) {
/**
* Delivery options
*/
$crmDeliveryList = $this->apiClient->deliveryTypesList();
if ($crmDeliveryList instanceof WC_Retailcrm_Response && $crmDeliveryList->isSuccessful()) {
$shippingOptionList = [];
foreach ($crmDeliveryList['deliveryTypes'] as $crmDelivery) {
if ($crmDelivery['active'] === false) {
continue;
}
$shipping_option_list[$retailcrm_shipping_type['code']] = $retailcrm_shipping_type['name'];
if (
isset($crmDelivery['sites'])
&& $crmDelivery['sites'] !== []
&& in_array($crmSite, $crmDelivery['sites']) === false
) {
continue;
}
$shippingOptionList[$crmDelivery['code']] = $crmDelivery['name'];
}
$wc_shipping_list = get_wc_shipping_methods();
@ -220,7 +231,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
'css' => 'min-width:350px;',
'class' => 'select',
'type' => 'select',
'options' => $shipping_option_list,
'options' => $shippingOptionList,
'desc_tip' => true,
];
}
@ -232,23 +243,31 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
*/
$crmPaymentsList = $this->apiClient->paymentTypesList();
if (!empty($crmPaymentsList) && $crmPaymentsList->isSuccessful()) {
$paymentsList = [];
if ($crmPaymentsList instanceof WC_Retailcrm_Response && $crmPaymentsList->isSuccessful()) {
$paymentOptionList = [];
$integrationPayments = [];
foreach ($crmPaymentsList['paymentTypes'] as $crmPaymentType) {
if ($crmPaymentType['active'] == false) {
foreach ($crmPaymentsList['paymentTypes'] as $crmPayment) {
if ($crmPayment['active'] === false) {
continue;
}
if (isset($crmPaymentType['integrationModule'])) {
$integrationPayments['code'][] = $crmPaymentType['code'];
$integrationPayments['name'][] = $crmPaymentType['name'];
$crmPaymentType['name'] .= ' - ' . __('Integration payment', 'retailcrm');
if (
isset($crmPayment['sites'])
&& $crmPayment['sites'] !== []
&& in_array($crmSite, $crmPayment['sites']) === false
) {
continue;
}
$paymentsList[$crmPaymentType['code']] = $crmPaymentType['name'];
if (isset($crmPayment['integrationModule'])) {
$integrationPayments['code'][] = $crmPayment['code'];
$integrationPayments['name'][] = $crmPayment['name'];
$crmPayment['name'] .= ' - ' . __('Integration payment', 'retailcrm');
}
$paymentOptionList[$crmPayment['code']] = $crmPayment['name'];
}
$wc_payment = WC_Payment_Gateways::instance();
@ -282,7 +301,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
'type' => 'select',
'title' => __($title, 'woocommerce'),
'class' => 'select',
'options' => $paymentsList,
'options' => $paymentOptionList,
'desc_tip' => true,
'description' => __($description, 'woocommerce'),
];

View File

@ -5,7 +5,7 @@ Tags: Интеграция, Simla.com, simla
Requires PHP: 7.0
Requires at least: 5.3
Tested up to: 6.0
Stable tag: 4.6.2
Stable tag: 4.6.3
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.3 =
* Types of deliveries and payments are displayed only for available stores
= 4.6.2 =
* Modified method getting an address by history

View File

@ -5,7 +5,7 @@
* Description: Integration plugin for WooCommerce & Simla.com
* Author: RetailDriver LLC
* Author URI: http://retailcrm.pro/
* Version: 4.6.2
* Version: 4.6.3
* Tested up to: 6.0
* WC requires at least: 5.4
* WC tested up to: 6.9

View File

@ -16,7 +16,7 @@
*
* @link https://wordpress.org/plugins/woo-retailcrm/
*
* @version 4.6.2
* @version 4.6.3
*
* @package RetailCRM
*/

View File

@ -75,6 +75,18 @@ class DataBaseRetailCrm
],
'active' => true
],
[
'name' => 'payment4',
'code' => 'payment4',
'active' => true,
'sites' => ['prestaShop']
],
[
'name' => 'payment5',
'code' => 'payment5',
'active' => true,
'sites' => ['woocommerce']
]
]
];
}
@ -93,6 +105,18 @@ class DataBaseRetailCrm
'name' => 'delivery2',
'code' => 'delivery2',
'active' => false
],
[
'name' => 'delivery3',
'code' => 'delivery3',
'active' => true,
'sites' => ['prestaShop']
],
[
'name' => 'delivery4',
'code' => 'delivery4',
'active' => true,
'sites' => ['woocommerce']
]
]
];

View File

@ -36,10 +36,12 @@ class WC_Retailcrm_Base_Test extends WC_Retailcrm_Test_Case_Helper
'paymentTypesList',
'statusesList',
'customFieldsList',
'getSingleSiteForKey',
]
)
->getMock();
$this->setMockResponse($this->apiMock, 'getSingleSiteForKey', ['woocommerce']);
$this->setMockOrderMethods();
$this->setMockDeliveryTypes();
$this->setMockPaymentTypes();