/**
  * Get estimated rates
  *
  * @param Quote $quote
  * @param int $country
  * @param string $postcode
  * @param int $regionId
  * @param string $region
  * @return \Magento\Quote\Api\Data\ShippingMethodInterface[] An array of shipping methods.
  */
 protected function getEstimatedRates(\Magento\Quote\Model\Quote $quote, $country, $postcode, $regionId, $region)
 {
     $output = [];
     $shippingAddress = $quote->getShippingAddress();
     $shippingAddress->setCountryId($country);
     $shippingAddress->setPostcode($postcode);
     $shippingAddress->setRegionId($regionId);
     $shippingAddress->setRegion($region);
     $shippingAddress->setCollectShippingRates(true);
     $shippingAddress->collectTotals();
     $shippingRates = $shippingAddress->getGroupedAllShippingRates();
     foreach ($shippingRates as $carrierRates) {
         foreach ($carrierRates as $rate) {
             $output[] = $this->converter->modelToDataObject($rate, $quote->getQuoteCurrencyCode());
         }
     }
     return $output;
 }
Beispiel #2
0
/**
 * 2016-11-15
 * @param O|Q $oq
 * @return Currency
 */
function dfp_currency($oq)
{
    return $oq instanceof O ? $oq->getOrderCurrency() : ($oq instanceof Q ? df_currency($oq->getQuoteCurrencyCode()) : df_error());
}