public getModifiers ( ) : Doctrine\Common\Collections\Collection | ||
return | Doctrine\Common\Collections\Collection |
public function visitOrder(OrderInterface $order) { $productTotal = $order->getProductTotal(); $modifiers = $order->getModifiers(); $targetCurrency = $order->getCurrency(); /** @var OrderSummaryInterface $summary */ $summary = $this->factory->create(); $summary->setGrossAmount($productTotal->getGrossPrice()); $summary->setNetAmount($productTotal->getNetPrice()); $summary->setTaxAmount($productTotal->getTaxAmount()); $modifiers->map(function (OrderModifierInterface $modifier) use($summary, $targetCurrency) { $baseCurrency = $modifier->getCurrency(); $grossAmount = $this->helper->convert($modifier->getGrossAmount(), $baseCurrency, $targetCurrency); $netAmount = $this->helper->convert($modifier->getNetAmount(), $baseCurrency, $targetCurrency); $taxAmount = $this->helper->convert($modifier->getTaxAmount(), $baseCurrency, $targetCurrency); if ($modifier->isSubtraction()) { $summary->setGrossAmount($summary->getGrossAmount() - $grossAmount); $summary->setNetAmount($summary->getNetAmount() - $netAmount); $summary->setTaxAmount($summary->getTaxAmount() - $taxAmount); } else { $summary->setGrossAmount($summary->getGrossAmount() + $grossAmount); $summary->setNetAmount($summary->getNetAmount() + $netAmount); $summary->setTaxAmount($summary->getTaxAmount() + $taxAmount); } }); $order->setSummary($summary); }