/**
* {@inheritdoc}
*/
public function calculateProduct(ShippingMethodInterface $shippingMethod, ProductInterface $product)
{
$baseCurrency = $product->getSellPrice()->getCurrency();
$targetCurrency = $shippingMethod->getCurrency()->getCode();
$totalGrossAmount = $this->currencyHelper->convert($product->getSellPrice()->getFinalGrossAmount(), $baseCurrency, $targetCurrency);
$ranges = $shippingMethod->getCosts();
$supportedRanges = $ranges->filter(function (ShippingMethodCostInterface $cost) use($totalGrossAmount) {
return $cost->getRangeFrom() <= $totalGrossAmount && $cost->getRangeTo() >= $totalGrossAmount;
});
if ($supportedRanges->count()) {
return $supportedRanges->first();
}
return null;
}