/** * 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(); }
/** * Get Shipping Price * * @return float */ public function getShippingPrice() { return $this->priceCurrency->convertAndFormat($this->shippingRate->getPrice()); }
/** * Get Shipping Price * * @return float */ public function getShippingPrice() { $price = $this->shippingRate->getPrice(); return $this->getQuote()->getStore()->convertPrice($price, true); }