public function determineOrderPrices(OrderInterface $order, PricingContextInterface $pricingContext = null) { // not implemented if ($pricingContext === null) { $pricingContext = new PricingContext(); } foreach ($order->getItems() as $item) { $this->determineOrderItemPrices($item, $pricingContext); } // summing it up $itemsTotalNet = 0; // updating prices for each item foreach ($order->getItems() as $item) { // this is the total value since we want to capture any calculations that happen on a specific item $itemsTotalNet += $item->getPrice('netValue'); } $order->setPrice('totalNet', $itemsTotalNet); $order->setPrice('totalValue', $itemsTotalNet); // if pricing context has taxation enabled we calculate the taxes with the percentage set // example taxRates : 0.10 for 10%, 0.25 for 25% if (isset($pricingContext['partner'])) { if ($partner = $pricingContext['partner']) { /** @var $partner \Vespolina\Entity\Partner\Partner */ if (count($partner->getPreferredPaymentProfile())) { /** @var $address \Vespolina\Entity\Partner\AddressInterface */ $paymentProfile = $partner->getPreferredPaymentProfile(); $rate = $this->taxProvider->getTaxByState($paymentProfile->getBillingState()); $totalTax = $itemsTotalNet * $rate; $order->setPrice('taxRate', $rate); $order->setPrice('taxes', $totalTax); $order->setPrice('totalValue', $itemsTotalNet + $totalTax); } } } }