예제 #1
0
 protected function collectShippingCost(ShippingMethodCostInterface $shippingMethodCost = null)
 {
     if (null !== $shippingMethodCost) {
         $cost = $shippingMethodCost->getCost();
         $baseCurrency = $cost->getCurrency();
         $grossAmount = $cost->getGrossAmount();
         return $this->helper->convert($grossAmount, $baseCurrency);
     }
     return 0;
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function collectTotalTaxAmount(CartInterface $cart, $targetCurrency = null)
 {
     $amount = 0;
     $cart->getProducts()->map(function (CartProductInterface $cartProduct) use(&$amount, &$targetCurrency) {
         $sellPrice = $cartProduct->getSellPrice();
         $baseCurrency = $sellPrice->getCurrency();
         $taxAmount = $sellPrice->getFinalTaxAmount();
         $amount += $this->helper->convert($taxAmount, $baseCurrency, $targetCurrency, $cartProduct->getQuantity());
     });
     return $amount;
 }
예제 #3
0
 /**
  * Prepares order shipping details
  *
  * @param OrderInterface              $order
  * @param ShippingMethodCostInterface $shippingMethodCost
  */
 protected function prepareShippingTotals(OrderInterface $order, ShippingMethodCostInterface $shippingMethodCost)
 {
     $cost = $shippingMethodCost->getCost();
     $baseCurrency = $cost->getCurrency();
     $shippingTotal = new OrderTotal();
     $shippingTotal->setGrossAmount($this->currencyHelper->convert($cost->getGrossAmount(), $baseCurrency, $order->getCurrency()));
     $shippingTotal->setNetAmount($this->currencyHelper->convert($cost->getNetAmount(), $baseCurrency, $order->getCurrency()));
     $shippingTotal->setTaxAmount($this->currencyHelper->convert($cost->getTaxAmount(), $baseCurrency, $order->getCurrency()));
     $shippingTotal->setTaxRate($this->currencyHelper->convert($cost->getTaxRate()));
     $shippingTotal->setCurrency($order->getCurrency());
     $order->setShippingTotal($shippingTotal);
 }
예제 #4
0
 /**
  * Converts the amount
  *
  * @param int|float   $price
  * @param null|string $baseCurrency
  * @param null|string $targetCurrency
  *
  * @return string
  */
 public function convertPrice($price, $baseCurrency = null, $targetCurrency = null, $quantity = 1)
 {
     return $this->helper->convert($price, $baseCurrency, $targetCurrency, $quantity);
 }
 /**
  * Returns the attribute's data
  *
  * @param ProductAttributeInterface $productAttribute
  *
  * @return array
  */
 protected function getAttributeData(ProductAttributeInterface $productAttribute)
 {
     $baseCurrency = $productAttribute->getSellPrice()->getCurrency();
     return ['id' => $productAttribute->getId(), 'finalPriceGross' => $this->currencyHelper->convertAndFormat($productAttribute->getSellPrice()->getFinalGrossAmount(), $baseCurrency), 'sellPriceGross' => $this->currencyHelper->convertAndFormat($productAttribute->getSellPrice()->getGrossAmount(), $baseCurrency), 'discountPriceGross' => $this->currencyHelper->convertAndFormat($productAttribute->getSellPrice()->getDiscountedGrossAmount(), $baseCurrency), 'stock' => $productAttribute->getStock(), 'symbol' => $productAttribute->getSymbol()];
 }