From a1a17f4978cbab1cb90f723293545f0d5abea17f Mon Sep 17 00:00:00 2001 From: Stas Demin Date: Mon, 17 Jun 2024 15:29:48 +0300 Subject: [PATCH] fix: merge insert services instead to rewrite services by get services from delivery settings --- src/Helpers/DeliveryCalc.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Helpers/DeliveryCalc.php b/src/Helpers/DeliveryCalc.php index a556a31..d6d9483 100644 --- a/src/Helpers/DeliveryCalc.php +++ b/src/Helpers/DeliveryCalc.php @@ -156,11 +156,14 @@ static function ($carry, $item) use ($package) { $api = $this->api; $deliveryMethod = $this->method; + $servicesParams = $deliveryParam['services']; + $this->rates = array_map(static function ($tariff) use ( $priceRules, $api, $deliveryParam, - $deliveryMethod + $deliveryMethod, + $servicesParams ) { $rule = Tariff::isTariffToOffice($tariff['meta_data'][MetaKeys::TARIFF_CODE]) ? $priceRules['office'] : $priceRules['door']; @@ -181,8 +184,9 @@ static function ($carry, $item) use ($package) { $deliveryParam['type'] = Tariff::getTariffType($deliveryParam['tariff_code']); $serviceList = Helper::getServices($deliveryMethod, $deliveryParam['tariff_code']); + if (!empty($serviceList)) { - $deliveryParam['services'] = $serviceList; + $deliveryParam['services'] = array_merge($serviceList, $servicesParams); } $tariffInfo = $api->calculateTariff($deliveryParam);