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;
     });
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function convert($amount, $baseCurrency = null, $targetCurrency = null, $quantity = 1)
 {
     return $this->converter->convert($amount, $baseCurrency, $targetCurrency, $quantity);
 }
Пример #4
0
 public function convert(float $amount, string $baseCurrency = null, string $targetCurrency = null, int $quantity = 1) : float
 {
     return $this->converter->convert($amount, $baseCurrency, $targetCurrency, $quantity);
 }