WellCommerce\Bundle\OrderBundle\Entity\OrderProductInterface::setSellPrice PHP Method

setSellPrice() public method

public setSellPrice ( WellCommerce\Bundle\AppBundle\Entity\PriceInterface $sellPrice )
$sellPrice WellCommerce\Bundle\AppBundle\Entity\PriceInterface
    public function setSellPrice(PriceInterface $sellPrice);

Usage Example

 private function refreshOrderProductSellPrice(OrderProductInterface $orderProduct)
 {
     if ($orderProduct->hasVariant()) {
         $baseSellPrice = $orderProduct->getVariant()->getSellPrice();
     } else {
         $baseSellPrice = $orderProduct->getProduct()->getSellPrice();
     }
     $baseCurrency = $baseSellPrice->getCurrency();
     $targetCurrency = $orderProduct->getOrder()->getCurrency();
     $grossAmount = $this->currencyHelper->convert($baseSellPrice->getFinalGrossAmount(), $baseCurrency, $targetCurrency);
     $netAmount = $this->currencyHelper->convert($baseSellPrice->getFinalNetAmount(), $baseCurrency, $targetCurrency);
     $taxAmount = $this->currencyHelper->convert($baseSellPrice->getFinalTaxAmount(), $baseCurrency, $targetCurrency);
     $sellPrice = $this->priceFactory->create();
     $sellPrice->setCurrency($targetCurrency);
     $sellPrice->setGrossAmount($grossAmount);
     $sellPrice->setNetAmount($netAmount);
     $sellPrice->setTaxAmount($taxAmount);
     $sellPrice->setTaxRate($baseSellPrice->getTaxRate());
     $orderProduct->setSellPrice($sellPrice);
 }