public function testGetFinalPricePreset()
 {
     $finalPrice = 9.99;
     $qty = 1;
     $this->model->setQty($qty);
     $this->model->setFinalPrice($finalPrice);
     $this->productTypeInstanceMock->expects($this->never())->method('priceFactory');
     $this->assertEquals($finalPrice, $this->model->getFinalPrice($qty));
 }
Example #2
0
 /**
  * Get formatted by currency product price
  *
  * @param   Product $product
  * @return  array || float
  */
 public function getFormatedPrice($product)
 {
     return $this->priceCurrency->format($product->getFinalPrice());
 }
Example #3
0
 /**
  * Calculate final price of selection
  * with take into account tier price
  *
  * @param  \Magento\Catalog\Model\Product $bundleProduct
  * @param  \Magento\Catalog\Model\Product $selectionProduct
  * @param  float                    $bundleQty
  * @param  float                    $selectionQty
  * @param  bool                       $multiplyQty
  * @param  bool                       $takeTierPrice
  * @return float
  */
 public function getSelectionFinalTotalPrice($bundleProduct, $selectionProduct, $bundleQty, $selectionQty, $multiplyQty = true, $takeTierPrice = true)
 {
     if (null === $bundleQty) {
         $bundleQty = 1.0;
     }
     if ($selectionQty === null) {
         $selectionQty = $selectionProduct->getSelectionQty();
     }
     if ($bundleProduct->getPriceType() == self::PRICE_TYPE_DYNAMIC) {
         $price = $selectionProduct->getFinalPrice($takeTierPrice ? $selectionQty : 1);
     } else {
         if ($selectionProduct->getSelectionPriceType()) {
             // percent
             $product = clone $bundleProduct;
             $product->setFinalPrice($this->getPrice($product));
             $this->_eventManager->dispatch('catalog_product_get_final_price', ['product' => $product, 'qty' => $bundleQty]);
             $price = $product->getData('final_price') * ($selectionProduct->getSelectionPriceValue() / 100);
         } else {
             // fixed
             $price = $selectionProduct->getSelectionPriceValue();
         }
     }
     if ($multiplyQty) {
         $price *= $selectionQty;
     }
     return min($price, $this->_applyGroupPrice($bundleProduct, $price), $this->_applyTierPrice($bundleProduct, $bundleQty, $price), $this->_applySpecialPrice($bundleProduct, $price));
 }
Example #4
0
 /**
  * Retrieve product final price
  *
  * @param ModelProduct $product
  * @return float
  */
 public function getFinalPrice($product)
 {
     return $product->getFinalPrice();
 }
Example #5
0
 /**
  * Use the defined helper to format the price
  *
  * @param Target $target
  * @param $result
  * @return string
  */
 public function afterGetName(Target $target, $result)
 {
     $formattedPrice = $this->_pricingHelper->currency($target->getFinalPrice(), true, false);
     return $result . ' for ONLY ' . $formattedPrice . '!';
 }
 /**
  * {@inheritdoc}
  */
 public function getFinalPrice($qty = null)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getFinalPrice');
     if (!$pluginInfo) {
         return parent::getFinalPrice($qty);
     } else {
         return $this->___callPlugins('getFinalPrice', func_get_args(), $pluginInfo);
     }
 }
 public function testSetGetFinalPrice()
 {
     $this->assertEquals(0, $this->_model->getFinalPrice());
     $this->_model->setFinalPrice(10);
     $this->assertEquals(10, $this->_model->getFinalPrice());
 }
Example #8
0
 /**
  * Get formatted by currency product price
  *
  * @param   Product $product
  * @return  array || float
  */
 public function getFormatedPrice($product)
 {
     return $this->_storeManager->getStore()->formatPrice($product->getFinalPrice());
 }