public function calculate(ShippingMethodInterface $shippingMethod, ShippingSubjectInterface $subject) : Collection { $ranges = $shippingMethod->getCosts(); $baseCurrency = $subject->getCurrency(); $targetCurrency = $shippingMethod->getCurrency()->getCode(); $grossAmount = $this->currencyConverter->convert($subject->getGrossPrice(), $baseCurrency, $targetCurrency); return $this->filterRanges($ranges, $grossAmount); }
public function calculate(ShippingMethodInterface $shippingMethod, ShippingSubjectInterface $subject) : Collection { $ranges = $shippingMethod->getCosts(); $baseCurrency = $subject->getCurrency(); $targetCurrency = $shippingMethod->getCurrency()->getCode(); $grossAmount = $this->currencyConverter->convert($subject->getGrossPrice(), $baseCurrency, $targetCurrency); return $ranges->filter(function (ShippingMethodCostInterface $cost) use($grossAmount) { return $cost->getRangeFrom() <= $grossAmount && $cost->getRangeTo() >= $grossAmount; }); }
/** * {@inheritdoc} */ public function convert($amount, $baseCurrency = null, $targetCurrency = null, $quantity = 1) { return $this->converter->convert($amount, $baseCurrency, $targetCurrency, $quantity); }
public function getCurrencyRate(string $baseCurrency = null, string $targetCurrency = null) : float { return $this->converter->getExchangeRate($baseCurrency, $targetCurrency); }
/** * {@inheritdoc} */ public function visitOrder(OrderInterface $order) { $currency = $order->getCurrency(); $currencyRate = $this->currencyConverter->getExchangeRate($currency); $order->setCurrencyRate($currencyRate); }