protected function collectShippingCost(ShippingMethodCostInterface $shippingMethodCost = null) { if (null !== $shippingMethodCost) { $cost = $shippingMethodCost->getCost(); $baseCurrency = $cost->getCurrency(); $grossAmount = $cost->getGrossAmount(); return $this->helper->convert($grossAmount, $baseCurrency); } return 0; }
/** * {@inheritdoc} */ public function collectTotalTaxAmount(CartInterface $cart, $targetCurrency = null) { $amount = 0; $cart->getProducts()->map(function (CartProductInterface $cartProduct) use(&$amount, &$targetCurrency) { $sellPrice = $cartProduct->getSellPrice(); $baseCurrency = $sellPrice->getCurrency(); $taxAmount = $sellPrice->getFinalTaxAmount(); $amount += $this->helper->convert($taxAmount, $baseCurrency, $targetCurrency, $cartProduct->getQuantity()); }); return $amount; }
/** * Prepares order shipping details * * @param OrderInterface $order * @param ShippingMethodCostInterface $shippingMethodCost */ protected function prepareShippingTotals(OrderInterface $order, ShippingMethodCostInterface $shippingMethodCost) { $cost = $shippingMethodCost->getCost(); $baseCurrency = $cost->getCurrency(); $shippingTotal = new OrderTotal(); $shippingTotal->setGrossAmount($this->currencyHelper->convert($cost->getGrossAmount(), $baseCurrency, $order->getCurrency())); $shippingTotal->setNetAmount($this->currencyHelper->convert($cost->getNetAmount(), $baseCurrency, $order->getCurrency())); $shippingTotal->setTaxAmount($this->currencyHelper->convert($cost->getTaxAmount(), $baseCurrency, $order->getCurrency())); $shippingTotal->setTaxRate($this->currencyHelper->convert($cost->getTaxRate())); $shippingTotal->setCurrency($order->getCurrency()); $order->setShippingTotal($shippingTotal); }
/** * Converts the amount * * @param int|float $price * @param null|string $baseCurrency * @param null|string $targetCurrency * * @return string */ public function convertPrice($price, $baseCurrency = null, $targetCurrency = null, $quantity = 1) { return $this->helper->convert($price, $baseCurrency, $targetCurrency, $quantity); }