protected function processRatesResponse($shipperResponse, $transactionId, $globals) { $carrierGroups = $shipperResponse->carrierGroups; $ratesArray = []; $timezone = $this->shipperDataHelper->getConfigValue('general/locale/timezone'); $configSetttings = $this->configSettingsFactory->create(['hideNotifications' => $this->shipperDataHelper->getConfigFlag('carriers/shipper/hide_notify'), 'transactionIdEnabled' => $this->shipperDataHelper->isTransactionIdEnabled(), 'locale' => $this->getLocaleInGlobals(), 'shipperHQCode' => $this->_code, 'shipperHQTitle' => $this->shipperDataHelper->getConfigFlag('carriers/shipper/title'), 'timezone' => $timezone]); $splitCarrierGroupDetail = []; foreach ($carrierGroups as $carrierGroup) { $carrierGroupDetail = $this->shipperRateHelper->extractCarrierGroupDetail($carrierGroup, $transactionId, $configSetttings); $this->setCarriergroupOnItems($carrierGroupDetail, $carrierGroup->products); //Pass off each carrier group to helper to decide best fit to process it. //Push result back into our array foreach ($carrierGroup->carrierRates as $carrierRate) { $this->carrierConfigHandler->saveCarrierResponseDetails($carrierRate, $carrierGroupDetail, false); $carrierResultWithRates = $this->shipperRateHelper->extractShipperHQRates($carrierRate, $carrierGroupDetail, $configSetttings, $splitCarrierGroupDetail); $ratesArray[] = $carrierResultWithRates; //push out event so other modules can save their data $this->eventManager->dispatch('shipperhq_carrier_rate_response_received', ['carrier_rate_response' => $carrierRate, 'carrier_group_detail' => $carrierGroupDetail]); } } //check for configuration here for display if ($shipperResponse->mergedRateResponse) { $mergedRatesArray = []; foreach ($shipperResponse->mergedRateResponse->carrierRates as $carrierRate) { $mergedResultWithRates = $this->shipperRateHelper->extractShipperHQMergedRates($carrierRate, $splitCarrierGroupDetail, $configSetttings, $transactionId); $mergedRatesArray[] = $mergedResultWithRates; } $ratesArray = $mergedRatesArray; } $carriergroupDescriber = $shipperResponse->globalSettings->carrierGroupDescription; if ($carriergroupDescriber != '') { $this->carrierConfigHandler->saveConfig($this->shipperDataHelper->getCarrierGroupDescPath(), $carriergroupDescriber); } $this->carrierConfigHandler->refreshConfig(); return $ratesArray; }