/**
  * Convert rate model to ShippingMethod data object
  * @param string $quoteCurrencyCode
  * @param \Magento\Sales\Model\Quote\Address\Rate $rateModel
  *
  * @return \Magento\Checkout\Service\V1\Data\Cart\ShippingMethod
  */
 public function modelToDataObject($rateModel, $quoteCurrencyCode)
 {
     /** @var \Magento\Directory\Model\Currency $currency */
     $currency = $this->storeManager->getStore()->getBaseCurrency();
     $errorMessage = $rateModel->getErrorMessage();
     $data = [ShippingMethod::CARRIER_CODE => $rateModel->getCarrier(), ShippingMethod::METHOD_CODE => $rateModel->getMethod(), ShippingMethod::CARRIER_TITLE => $rateModel->getCarrierTitle(), ShippingMethod::METHOD_TITLE => $rateModel->getMethodTitle(), ShippingMethod::SHIPPING_AMOUNT => $currency->convert($rateModel->getPrice(), $quoteCurrencyCode), ShippingMethod::BASE_SHIPPING_AMOUNT => $rateModel->getPrice(), ShippingMethod::AVAILABLE => empty($errorMessage)];
     $this->builder->populateWithArray($data);
     return $this->builder->create();
 }
示例#2
0
 /**
  * Get Shipping Price
  *
  * @return float
  */
 public function getShippingPrice()
 {
     return $this->priceCurrency->convertAndFormat($this->shippingRate->getPrice());
 }
示例#3
0
文件: Price.php 项目: aiesh/magento2
 /**
  * Get Shipping Price
  *
  * @return float
  */
 public function getShippingPrice()
 {
     $price = $this->shippingRate->getPrice();
     return $this->getQuote()->getStore()->convertPrice($price, true);
 }
示例#4
0
 /**
  * Add shipping rate
  *
  * @param \Magento\Sales\Model\Quote\Address\Rate $rate
  * @return $this
  */
 public function addShippingRate(\Magento\Sales\Model\Quote\Address\Rate $rate)
 {
     $rate->setAddress($this);
     $this->getShippingRatesCollection()->addItem($rate);
     return $this;
 }