getProductTotal() public method

public getProductTotal ( ) : WellCommerce\Bundle\OrderBundle\Entity\OrderProductTotalInterface
return WellCommerce\Bundle\OrderBundle\Entity\OrderProductTotalInterface
 public function visitOrder(OrderInterface $order)
 {
     $productTotal = $order->getProductTotal();
     $modifiers = $order->getModifiers();
     $targetCurrency = $order->getCurrency();
     /** @var OrderSummaryInterface $summary */
     $summary = $this->factory->create();
     $summary->setGrossAmount($productTotal->getGrossPrice());
     $summary->setNetAmount($productTotal->getNetPrice());
     $summary->setTaxAmount($productTotal->getTaxAmount());
     $modifiers->map(function (OrderModifierInterface $modifier) use($summary, $targetCurrency) {
         $baseCurrency = $modifier->getCurrency();
         $grossAmount = $this->helper->convert($modifier->getGrossAmount(), $baseCurrency, $targetCurrency);
         $netAmount = $this->helper->convert($modifier->getNetAmount(), $baseCurrency, $targetCurrency);
         $taxAmount = $this->helper->convert($modifier->getTaxAmount(), $baseCurrency, $targetCurrency);
         if ($modifier->isSubtraction()) {
             $summary->setGrossAmount($summary->getGrossAmount() - $grossAmount);
             $summary->setNetAmount($summary->getNetAmount() - $netAmount);
             $summary->setTaxAmount($summary->getTaxAmount() - $taxAmount);
         } else {
             $summary->setGrossAmount($summary->getGrossAmount() + $grossAmount);
             $summary->setNetAmount($summary->getNetAmount() + $netAmount);
             $summary->setTaxAmount($summary->getTaxAmount() + $taxAmount);
         }
     });
     $order->setSummary($summary);
 }
 /**
  * {@inheritdoc}
  */
 public function visitOrder(OrderInterface $order)
 {
     $orderProductTotal = $order->getProductTotal();
     $orderTotalDetail = $this->initResource();
     $orderTotalDetail->setOrderTotal($orderProductTotal);
     $orderTotalDetail->setOrder($order);
     $order->addTotal($orderTotalDetail);
 }
 public function visitOrder(OrderInterface $order)
 {
     $summary = $order->getProductTotal();
     $summary->setQuantity($this->calculateQuantity($order));
     $summary->setWeight($this->calculateWeight($order));
     $summary->setNetPrice($this->calculateNetPrice($order));
     $summary->setGrossPrice($this->calculateGrossPrice($order));
     $summary->setTaxAmount($this->calculateTaxAmount($order));
 }
 private function calculateCouponModifier(CouponInterface $coupon, OrderInterface $order) : float
 {
     $modifierType = $coupon->getModifierType();
     $modifierValue = $coupon->getModifierValue();
     $baseCurrency = $coupon->getCurrency();
     $targetCurrency = $order->getCurrency();
     $totalGrossPrice = $order->getProductTotal()->getGrossPrice();
     if ('%' === $modifierType) {
         return $modifierValue / 100;
     }
     if ('-' === $modifierType) {
         $modifierValue = $this->currencyHelper->convert($modifierValue, $baseCurrency, $targetCurrency);
         return $modifierValue >= $totalGrossPrice ? 1 : $modifierValue / $totalGrossPrice;
     }
     return 1;
 }
 /**
  * {@inheritdoc}
  */
 public function visitOrder(OrderInterface $order)
 {
     if (null === $order->getCoupon()) {
         $orderTotal = new OrderTotal();
         $discount = $this->getDiscountForClient($order->getClient());
         if ($discount > 0) {
             $productTotal = $order->getProductTotal();
             $orderTotal->setCurrency($order->getCurrency());
             $orderTotal->setGrossAmount($productTotal->getGrossAmount() * $discount);
             $orderTotal->setNetAmount($productTotal->getNetAmount() * $discount);
             $orderTotal->setTaxAmount($productTotal->getTaxAmount() * $discount);
             $orderTotalDetail = $this->initResource();
             $orderTotalDetail->setOrderTotal($orderTotal);
             $orderTotalDetail->setModifierType('%');
             $orderTotalDetail->setModifierValue($discount);
             $orderTotalDetail->setOrder($order);
             $orderTotalDetail->setSubtraction(true);
             $order->addTotal($orderTotalDetail);
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function visitOrder(OrderInterface $order)
 {
     if (null !== $order->getCoupon()) {
         $productTotal = $order->getProductTotal();
         $coupon = $order->getCoupon();
         $modifier = $this->calculateModifierValue($coupon, $productTotal->getGrossAmount(), $order->getCurrency());
         if ($modifier > 0) {
             $orderTotal = new OrderTotal();
             $orderTotal->setCurrency($order->getCurrency());
             $orderTotal->setGrossAmount($productTotal->getGrossAmount() * $modifier);
             $orderTotal->setNetAmount($productTotal->getNetAmount() * $modifier);
             $orderTotal->setTaxAmount($productTotal->getTaxAmount() * $modifier);
             $orderTotalDetail = $this->initResource();
             $orderTotalDetail->setOrderTotal($orderTotal);
             $orderTotalDetail->setModifierType($coupon->getModifierType());
             $orderTotalDetail->setModifierValue($modifier);
             $orderTotalDetail->setOrder($order);
             $orderTotalDetail->setSubtraction(true);
             $order->addTotal($orderTotalDetail);
         }
     }
 }
Esempio n. 7
0
 public function getTaxAmount() : float
 {
     return $this->order->getProductTotal()->getTaxAmount();
 }
 /**
  * Creates PayPal payment details from given order
  *
  * @param OrderInterface $order
  *
  * @return Details
  */
 protected function createDetails(OrderInterface $order) : Details
 {
     $details = new Details();
     $details->setShipping($order->getShippingTotal()->getNetAmount());
     $details->setTax($order->getOrderTotal()->getTaxAmount());
     $details->setSubtotal($order->getProductTotal()->getNetAmount());
     return $details;
 }
 private function createDetails(OrderInterface $order) : Details
 {
     $shippingCosts = $order->getModifier('shipping_cost');
     $details = new Details();
     $details->setShipping($shippingCosts->getNetAmount());
     $details->setTax($order->getSummary()->getTaxAmount());
     $details->setSubtotal($order->getProductTotal()->getNetPrice());
     return $details;
 }