public function requoteShipment(\FS\Components\Order\ShoppingOrder $order) { $options = $this->getApplicationContext()->getComponent('\\FS\\Components\\Options'); $client = $this->getApplicationContext()->getComponent('\\FS\\Components\\Http\\Client'); $command = $this->getApplicationContext()->getComponent('\\FS\\Components\\Shipping\\Command'); $factory = $this->getApplicationContext()->getComponent('\\FS\\Components\\Shipping\\Factory\\ShoppingOrderRateRequestFactory'); $notifier = $this->getApplicationContext()->getComponent('\\FS\\Components\\Notifier'); $rateProcessorFactory = $this->getApplicationContext()->getComponent('\\FS\\Components\\Shipping\\RateProcessor\\Factory\\RateProcessorFactory'); $response = $command->quote($client, $factory->setPayload(array('order' => $order, 'options' => $options))->getRequest()); if (!$response->isSuccessful()) { $notifier->error('Flagship Shipping has some difficulty in retrieving the rates. Please contact site administrator for assistance.<br/>'); return; } $rates = $response->getBody(); $rates = $rateProcessorFactory->getRateProcessor('ProcessRate')->getProcessedRates($rates, array('factory' => $rateProcessorFactory, 'options' => $options, 'instanceId' => property_exists($method, 'instance_id') ? $method->instance_id : false)); $wcShippingRates = array(); foreach ($rates as $rate) { $wcShippingRates[$rate['id']] = $rate['label'] . ' $' . $rate['cost']; } if ($wcShippingRates) { $order->setAttribute('flagship_shipping_requote_rates', $wcShippingRates); } }