private function refreshOrderProductBuyPrice(OrderProductInterface $orderProduct) { $baseBuyPrice = $orderProduct->getProduct()->getBuyPrice(); $baseCurrency = $baseBuyPrice->getCurrency(); $targetCurrency = $orderProduct->getOrder()->getCurrency(); $grossAmount = $this->currencyHelper->convert($baseBuyPrice->getGrossAmount(), $baseCurrency, $targetCurrency); $netAmount = $this->currencyHelper->convert($baseBuyPrice->getNetAmount(), $baseCurrency, $targetCurrency); $taxAmount = $this->currencyHelper->convert($baseBuyPrice->getTaxAmount(), $baseCurrency, $targetCurrency); $buyPrice = $this->priceFactory->create(); $buyPrice->setCurrency($targetCurrency); $buyPrice->setGrossAmount($grossAmount); $buyPrice->setNetAmount($netAmount); $buyPrice->setTaxAmount($taxAmount); $buyPrice->setTaxRate($baseBuyPrice->getTaxRate()); $orderProduct->setBuyPrice($buyPrice); }
/** * Creates a single PayPal item from given order product * * @param OrderProductInterface $orderProduct * * @return Item */ protected function createItem(OrderProductInterface $orderProduct) : Item { $item = new Item(); $item->setName($orderProduct->getProduct()->translate()->getName()); $item->setCurrency($orderProduct->getSellPrice()->getCurrency()); $item->setQuantity($orderProduct->getQuantity()); $item->setSku($orderProduct->getProduct()->getSku()); $item->setPrice($orderProduct->getSellPrice()->getNetAmount()); $item->setTax($orderProduct->getSellPrice()->getTaxAmount()); return $item; }