2020-07-22 15:11:27 +03:00
|
|
|
<?php
|
2020-09-28 13:02:03 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class RetailCrmService
|
|
|
|
*/
|
2020-07-22 15:11:27 +03:00
|
|
|
class RetailCrmService
|
|
|
|
{
|
2020-09-28 13:02:03 +03:00
|
|
|
/**
|
|
|
|
* @param $order
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public static function unsetIntegrationDeliveryFields(array $order): array
|
2020-07-22 15:11:27 +03:00
|
|
|
{
|
2020-09-28 13:02:03 +03:00
|
|
|
$integrationDelivery = RetailcrmConfigProvider::getCrmIntegrationDelivery();
|
|
|
|
|
|
|
|
if (isset($order['delivery']['code'])) {
|
|
|
|
$deliveryCode = $order['delivery']['code'];
|
|
|
|
|
|
|
|
if (!empty($integrationDelivery[$deliveryCode])
|
|
|
|
&& $integrationDelivery[$deliveryCode] !== 'sdek'
|
|
|
|
&& $integrationDelivery[$deliveryCode] !== 'dpd'
|
|
|
|
&& $integrationDelivery[$deliveryCode] !== 'newpost'
|
|
|
|
) {
|
|
|
|
unset($order['weight']);
|
|
|
|
unset($order['firstName']);
|
|
|
|
unset($order['lastName']);
|
|
|
|
unset($order['phone']);
|
|
|
|
unset($order['delivery']['cost']);
|
|
|
|
unset($order['paymentType']);
|
|
|
|
unset($order['shipmentStore']);
|
|
|
|
unset($order['delivery']['address']);
|
|
|
|
unset($order['delivery']['data']);
|
|
|
|
}
|
|
|
|
|
2020-07-22 15:11:27 +03:00
|
|
|
switch ($integrationDelivery[$deliveryCode]) {
|
|
|
|
case "sdek":
|
2020-09-28 13:02:03 +03:00
|
|
|
unset($order['weight']);
|
2020-07-22 15:11:27 +03:00
|
|
|
unset($order['length']);
|
|
|
|
unset($order['width']);
|
2020-09-28 13:02:03 +03:00
|
|
|
unset($order['height']);
|
|
|
|
unset($order['phone']);
|
|
|
|
unset($order['delivery']['cost']);
|
|
|
|
unset($order['paymentType']);
|
|
|
|
unset($order['shipmentStore']);
|
|
|
|
unset($order['number']);
|
|
|
|
unset($order['delivery']['address']);
|
|
|
|
unset($order['delivery']['data']);
|
2020-07-22 15:11:27 +03:00
|
|
|
break;
|
|
|
|
case "dpd":
|
2020-09-28 13:02:03 +03:00
|
|
|
unset($order['weight']);
|
2020-07-22 15:11:27 +03:00
|
|
|
unset($order['manager']);
|
2020-09-28 13:02:03 +03:00
|
|
|
unset($order['phone']);
|
2020-07-22 15:11:27 +03:00
|
|
|
unset($order['firstName']);
|
|
|
|
unset($order['lastName']);
|
2020-09-28 13:02:03 +03:00
|
|
|
unset($order['delivery']['cost']);
|
|
|
|
unset($order['paymentType']);
|
|
|
|
unset($order['shipmentStore']);
|
|
|
|
unset($order['delivery']['address']);
|
|
|
|
unset($order['delivery']['data']);
|
2020-07-22 15:11:27 +03:00
|
|
|
break;
|
|
|
|
case "newpost":
|
2020-09-28 13:02:03 +03:00
|
|
|
unset($order['weight']);
|
2020-07-22 15:11:27 +03:00
|
|
|
unset($order['customer']);
|
2020-09-28 13:02:03 +03:00
|
|
|
unset($order['phone']);
|
|
|
|
unset($order['shipmentStore']);
|
|
|
|
unset($order['paymentType']);
|
|
|
|
unset($order['delivery']['cost']);
|
|
|
|
unset($order['delivery']['address']);
|
|
|
|
unset($order['delivery']['data']);
|
2020-07-22 15:11:27 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-09-28 13:02:03 +03:00
|
|
|
|
2020-07-22 15:11:27 +03:00
|
|
|
return $order;
|
|
|
|
}
|
|
|
|
}
|