コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function createFromCartProduct(CartProductInterface $cartProduct, OrderInterface $order)
 {
     $orderProduct = new OrderProduct();
     $product = $cartProduct->getProduct();
     $attribute = $cartProduct->getAttribute();
     $sellPrice = $cartProduct->getSellPrice();
     $baseCurrency = $sellPrice->getCurrency();
     $targetCurrency = $order->getCurrency();
     $grossAmount = $this->currencyHelper->convert($sellPrice->getFinalGrossAmount(), $baseCurrency, $targetCurrency);
     $netAmount = $this->currencyHelper->convert($sellPrice->getFinalNetAmount(), $baseCurrency, $targetCurrency);
     $taxAmount = $this->currencyHelper->convert($sellPrice->getFinalTaxAmount(), $baseCurrency, $targetCurrency);
     $sellPrice = new Price();
     $sellPrice->setGrossAmount($grossAmount);
     $sellPrice->setNetAmount($netAmount);
     $sellPrice->setTaxAmount($taxAmount);
     $sellPrice->setTaxRate($sellPrice->getTaxRate());
     $sellPrice->setCurrency($targetCurrency);
     $orderProduct->setSellPrice($sellPrice);
     $orderProduct->setBuyPrice($product->getBuyPrice());
     $orderProduct->setQuantity($cartProduct->getQuantity());
     $orderProduct->setWeight($cartProduct->getWeight());
     $orderProduct->setProductAttribute($attribute);
     $orderProduct->setProduct($product);
     return $orderProduct;
 }
コード例 #2
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;
 }
コード例 #3
0
ファイル: OrderFactory.php プロジェクト: pguso/WellCommerce
 protected function prepareOrderShippingDetails(CartInterface $cart, OrderInterface $order)
 {
     $cost = $cart->getShippingMethodCost()->getCost();
     $grossAmount = $this->currencyHelper->convert($cost->getGrossAmount(), $cost->getCurrency(), $order->getCurrency());
     $taxRate = $cost->getTaxRate();
     $orderTotal = $this->orderTotalFactory->createFromSpecifiedValues($grossAmount, $taxRate, $order->getCurrency());
     $order->setShippingTotal($orderTotal);
 }
コード例 #4
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;
 }
コード例 #5
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);
 }
コード例 #6
0
 /**
  * Returns the attribute's data
  *
  * @param ProductAttributeInterface $productAttribute
  *
  * @return array
  */
 protected function getAttributeData(ProductAttributeInterface $productAttribute)
 {
     $sellPrice = $productAttribute->getSellPrice();
     $baseCurrency = $sellPrice->getCurrency();
     return ['id' => $productAttribute->getId(), 'finalPriceGross' => $this->currencyHelper->convertAndFormat($sellPrice->getFinalGrossAmount(), $baseCurrency), 'sellPriceGross' => $this->currencyHelper->convertAndFormat($sellPrice->getGrossAmount(), $baseCurrency), 'discountPriceGross' => $this->currencyHelper->convertAndFormat($sellPrice->getDiscountedGrossAmount(), $baseCurrency), 'stock' => $productAttribute->getStock(), 'symbol' => $productAttribute->getSymbol()];
 }