/** * Adds all products to order * * @param CartInterface $cart * @param OrderInterface $order */ protected function prepareOrderProducts(CartInterface $cart, OrderInterface $order) { $cart->getProducts()->map(function (CartProductInterface $cartProduct) use($order) { $orderProduct = $this->orderProductFactory->createFromCartProduct($cartProduct, $order); $orderProduct->setOrder($order); $order->addProduct($orderProduct); }); }
/** * {@inheritdoc} */ public function collectTotalTaxAmount(CartInterface $cart, $targetCurrency = null) { $amount = 0; $cart->getProducts()->map(function (CartProductInterface $cartProduct) use(&$amount, &$targetCurrency) { $sellPrice = $cartProduct->getSellPrice(); $baseCurrency = $sellPrice->getCurrency(); $taxAmount = $sellPrice->getFinalTaxAmount(); $amount += $this->helper->convert($taxAmount, $baseCurrency, $targetCurrency, $cartProduct->getQuantity()); }); return $amount; }