protected function getVariantId(OrderProductInterface $orderProduct) { if ($orderProduct->hasVariant()) { return $orderProduct->getVariant()->getId(); } return 0; }
/** * Updates an existing order's product * * @param OrderProductInterface $orderProduct * @param array $productValues */ protected function updateOrderProduct(OrderProductInterface $orderProduct, array $productValues) { $sellPrice = $orderProduct->getSellPrice(); $grossAmount = $productValues['gross_amount']; $taxRate = $orderProduct->getSellPrice()->getTaxRate(); $netAmount = TaxHelper::calculateNetPrice($grossAmount, $taxRate); $sellPrice->setTaxRate($taxRate); $sellPrice->setTaxAmount($grossAmount - $netAmount); $sellPrice->setNetAmount($netAmount); $sellPrice->setGrossAmount($grossAmount); $orderProduct->setWeight($productValues['weight']); $orderProduct->setQuantity($productValues['quantity']); }
private function refreshOrderProductVariantOptions(OrderProductInterface $orderProduct) { if ($orderProduct->hasVariant()) { $options = $this->variantHelper->getVariantOptions($orderProduct->getVariant()); $orderProduct->setOptions($options); } }
/** * 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; }
public function __construct(OrderProductInterface $orderProduct) { $message = sprintf(self::ERROR_MESSAGE, $orderProduct->getId()); parent::__construct($message); }