/** * Calculate realtime rates * * @param array $shippings List realtime shippings * @return array Rates list */ private static function _calculateRealTimeRates($shippings) { $_rates = array(); RealtimeServices::clearStack(); foreach ($shippings as $shipping_key => $shipping) { $error = RealtimeServices::register($shipping_key, $shipping); if (!empty($error)) { $_rates[] = array('price' => false, 'keys' => $shipping['keys'], 'error' => $error); } } $rates = RealtimeServices::getRates(); foreach ($rates as $rate) { $_rates[] = array('price' => $rate['price'], 'keys' => $shippings[$rate['shipping_key']]['keys'], 'error' => $rate['error'], 'delivery_time' => isset($rate['delivery_time']) ? $rate['delivery_time'] : false); } return $_rates; }
/** * Calculate realtime rates * * @param array $shippings List realtime shippings * @return array Rates list */ private static function _calculateRealTimeRates($shippings) { $_rates = array(); RealtimeServices::clearStack(); foreach ($shippings as $shipping_key => $shipping) { // use free rates for free shipping if (!self::isFreeShipping($shipping)) { $shipping['package_info'] = $shipping['package_info_full']; } unset($shipping['package_info_full']); $error = RealtimeServices::register($shipping_key, $shipping); if (!empty($error)) { $_rates[] = array('price' => false, 'keys' => $shipping['keys'], 'error' => $error); } } $rates = RealtimeServices::getRates(); foreach ($rates as $rate) { $_rates[] = array('price' => $rate['price'], 'keys' => $shippings[$rate['shipping_key']]['keys'], 'error' => $rate['error'], 'service_delivery_time' => isset($rate['delivery_time']) ? $rate['delivery_time'] : false, 'delivery_time' => $shippings[$rate['shipping_key']]['delivery_time']); } return $_rates; }