/**
  * {@inheritdoc}
  */
 public function collect(CartInterface $cart)
 {
     $totals = $cart->getTotals();
     $totalGrossPrice = $totals->getGrossPrice();
     $shippingCost = $this->collectShippingCost($cart->getShippingMethodCost());
     return round($totalGrossPrice + $shippingCost, 2);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function visitCart(CartInterface $cart)
 {
     $totals = $cart->getTotals();
     $totalGrossAmount = $this->cartTotalsCollector->collectTotalGrossAmount($cart);
     $totalNetAmount = $this->cartTotalsCollector->collectTotalNetAmount($cart);
     $totalTaxAmount = $this->cartTotalsCollector->collectTotalTaxAmount($cart);
     $totalQuantity = $this->cartTotalsCollector->collectTotalQuantity($cart);
     $totalQWeight = $this->cartTotalsCollector->collectTotalWeight($cart);
     $totals->setQuantity($totalQuantity);
     $totals->setWeight($totalQWeight);
     $totals->setGrossPrice($totalGrossAmount);
     $totals->setNetPrice($totalNetAmount);
     $totals->setTaxAmount($totalTaxAmount);
 }
Exemplo n.º 3
0
 /**
  * Prepares order product totals
  *
  * @param OrderInterface              $order
  * @param ShippingMethodCostInterface $shippingMethodCost
  */
 protected function prepareProductTotals(OrderInterface $order, CartInterface $cart)
 {
     $cartTotals = $cart->getTotals();
     $baseCurrency = $cart->getCurrency();
     $productTotal = new OrderTotal();
     $productTotal->setGrossAmount($this->currencyHelper->convert($cartTotals->getGrossPrice(), $baseCurrency, $order->getCurrency()));
     $productTotal->setNetAmount($this->currencyHelper->convert($cartTotals->getNetPrice(), $baseCurrency, $order->getCurrency()));
     $productTotal->setTaxAmount($this->currencyHelper->convert($cartTotals->getTaxAmount(), $baseCurrency, $order->getCurrency()));
     $productTotal->setCurrency($order->getCurrency());
     $order->setProductTotal($productTotal);
 }