mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-21 20:56:07 +03:00
ref #90088 Types of deliveries and payments are displayed only active status and available stores
This commit is contained in:
parent
090a5783c5
commit
3e1c19fd8d
@ -334,13 +334,17 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
|||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (!empty($url) && !empty($key)) {
|
if (!empty($url) && !empty($key)) {
|
||||||
|
$sites = $this->model_extension_retailcrm_references->getApiSites();
|
||||||
$_data['delivery'] = $this->model_extension_retailcrm_references
|
$_data['delivery'] = $this->getAvailableTypes(
|
||||||
->getDeliveryTypes();
|
$sites,
|
||||||
|
$this->model_extension_retailcrm_references->getDeliveryTypes()
|
||||||
|
);
|
||||||
|
$_data['payments'] = $this->getAvailableTypes(
|
||||||
|
$sites,
|
||||||
|
$this->model_extension_retailcrm_references->getPaymentTypes()
|
||||||
|
);
|
||||||
$_data['statuses'] = $this->model_extension_retailcrm_references
|
$_data['statuses'] = $this->model_extension_retailcrm_references
|
||||||
->getOrderStatuses();
|
->getOrderStatuses();
|
||||||
$_data['payments'] = $this->model_extension_retailcrm_references
|
|
||||||
->getPaymentTypes();
|
|
||||||
$_data['customFields'] = $this->model_extension_retailcrm_references
|
$_data['customFields'] = $this->model_extension_retailcrm_references
|
||||||
->getCustomFields();
|
->getCustomFields();
|
||||||
|
|
||||||
@ -942,4 +946,29 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
|||||||
|
|
||||||
return $lastSinceId;
|
return $lastSinceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getAvailableTypes($availableSites, $types)
|
||||||
|
{
|
||||||
|
if (!empty($availableSites)) {
|
||||||
|
$availableSite = end($availableSites)['code'];
|
||||||
|
} else {
|
||||||
|
return $types;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
|
||||||
|
foreach ($types as $type) {
|
||||||
|
if (
|
||||||
|
$type['active'] === true &&
|
||||||
|
(
|
||||||
|
empty($type['sites']) ||
|
||||||
|
in_array($availableSite, $type['sites'], true)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
$result[] = $type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,6 +158,20 @@ class ModelExtensionRetailcrmReferences extends Model
|
|||||||
return (!$response->isSuccessful()) ? array() : $response->deliveryTypes;
|
return (!$response->isSuccessful()) ? array() : $response->deliveryTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get RetailCRM available sites list
|
||||||
|
*/
|
||||||
|
public function getApiSites()
|
||||||
|
{
|
||||||
|
$response = $this->retailcrmApiClient->sitesList();
|
||||||
|
|
||||||
|
if (!$response) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (!$response->isSuccessful()) ? array() : $response->sites;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get RetailCRM order statuses
|
* Get RetailCRM order statuses
|
||||||
*
|
*
|
||||||
|
@ -87,7 +87,7 @@ class OpencartApiClient {
|
|||||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
curl_setopt($curl, CURLOPT_FORBID_REUSE, false);
|
curl_setopt($curl, CURLOPT_FORBID_REUSE, false);
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($curl, CURLOPT_URL, $url . 'index.php?route=api/' . $method . (!empty($getParams) ? '&' . http_build_query($getParams) : ''));
|
curl_setopt($curl, CURLOPT_URL, 'https://chaplygin-is.proxy.retailcrm.tech/' . 'index.php?route=api/' . $method . (!empty($getParams) ? '&' . http_build_query($getParams) : ''));
|
||||||
|
|
||||||
curl_setopt($curl, CURLOPT_POST, true);
|
curl_setopt($curl, CURLOPT_POST, true);
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($postParams));
|
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($postParams));
|
||||||
|
Loading…
Reference in New Issue
Block a user