mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-21 20:56:07 +03:00
task 63938 перед отправкой в CRM очищаем пустые поля
This commit is contained in:
parent
82ff3628cd
commit
30e6cb9886
@ -67,10 +67,12 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
}
|
||||
|
||||
if ($create) {
|
||||
$order = self::filterRecursive($order);
|
||||
$retailcrmApiClient->ordersCreate($order);
|
||||
} else {
|
||||
$order_payment = reset($order['payments']);
|
||||
unset($order['payments']);
|
||||
$order = self::filterRecursive($order);
|
||||
$response = $retailcrmApiClient->ordersEdit($order);
|
||||
|
||||
if ($this->settings[$this->moduleTitle . '_apiversion'] == 'v5' && $response->isSuccessful()) {
|
||||
@ -396,4 +398,29 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
|
||||
return $resultTotals;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive array filter
|
||||
*
|
||||
* @param array $haystack input array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function filterRecursive($haystack)
|
||||
{
|
||||
foreach ($haystack as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$haystack[$key] = self::filterRecursive($haystack[$key]);
|
||||
}
|
||||
if ($haystack[$key] === null
|
||||
|| $haystack[$key] === ''
|
||||
|| (is_array($haystack[$key]) && empty($haystack[$key]))
|
||||
) {
|
||||
unset($haystack[$key]);
|
||||
} elseif (!is_array($value)) {
|
||||
$haystack[$key] = trim($value);
|
||||
}
|
||||
}
|
||||
return $haystack;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user