public function visitOrder(OrderInterface $order) { $order->getProducts()->map(function (OrderProductInterface $orderProduct) { $this->refreshOrderProductSellPrice($orderProduct); $this->refreshOrderProductBuyPrice($orderProduct); $this->refreshOrderProductVariantOptions($orderProduct); }); }
public function changeOrderProductQuantity(OrderProductInterface $orderProduct, OrderInterface $order, int $quantity) { if (false === $order->getProducts()->contains($orderProduct)) { throw new ChangeOrderProductQuantityException($orderProduct); } if ($quantity < 1) { $this->deleteOrderProduct($orderProduct, $order); } else { $orderProduct->setQuantity($quantity); } $this->updateResource($order); }
/** * Creates a collection of PayPal items for given order * * @param OrderInterface $order * * @return ItemList */ protected function createItemList(OrderInterface $order) : ItemList { $itemList = new ItemList(); $order->getProducts()->map(function (OrderProductInterface $orderProduct) use($itemList) { $itemList->addItem($this->createItem($orderProduct)); }); return $itemList; }
/** * {@inheritdoc} */ public function calculateTotalTaxAmount(OrderInterface $order) { $amount = 0; $targetCurrency = $order->getCurrency(); $order->getProducts()->map(function (OrderProductInterface $orderProduct) use(&$amount, $targetCurrency) { $sellPrice = $orderProduct->getSellPrice(); $baseCurrency = $sellPrice->getCurrency(); $taxAmount = $sellPrice->getTaxAmount(); $amount += $this->currencyHelper->convert($taxAmount, $baseCurrency, $targetCurrency, $orderProduct->getQuantity()); }); return $amount; }
private function calculateTaxAmount(OrderInterface $order) : float { $targetCurrency = $order->getCurrency(); $tax = 0; $order->getProducts()->map(function (OrderProductInterface $orderProduct) use(&$tax, $targetCurrency) { $sellPrice = $orderProduct->getSellPrice(); $baseCurrency = $sellPrice->getCurrency(); $taxAmount = $sellPrice->getTaxAmount(); $tax += $this->helper->convert($taxAmount, $baseCurrency, $targetCurrency, $orderProduct->getQuantity()); }); return $tax; }