/** * Process bundle options selection for prepare view json * * @param \Magento\Framework\Event\Observer $observer * @return $this */ public function updateBundleProductOptions(\Magento\Framework\Event\Observer $observer) { if (!$this->_weeeData->isEnabled()) { return $this; } $response = $observer->getEvent()->getResponseObject(); $selection = $observer->getEvent()->getSelection(); $options = $response->getAdditionalOptions(); $_product = $this->_registry->registry('current_product'); $typeDynamic = \Magento\Bundle\Block\Adminhtml\Catalog\Product\Edit\Tab\Attributes\Extend::DYNAMIC; if (!$_product || $_product->getPriceType() != $typeDynamic) { return $this; } $amount = $this->_weeeData->getAmount($selection); $attributes = $this->_weeeData->getProductWeeeAttributes($_product, null, null, null, $this->_weeeData->isTaxable()); $amountInclTaxes = $this->_weeeData->getAmountInclTaxes($attributes); $taxes = $amountInclTaxes - $amount; $options['plusDisposition'] = $amount; $options['plusDispositionTax'] = $taxes < 0 ? 0 : $taxes; // Exclude Weee amount from excluding tax amount if (!$this->_weeeData->typeOfDisplay(array(0, 1, 4))) { $options['exclDisposition'] = true; } $response->setAdditionalOptions($options); return $this; }
public function testGetAmount() { $this->assertEquals('11.26', $this->_helperData->getAmount($this->_product)); }
/** * Obtain amount * * @param SaleableInterface $saleableItem * @return float */ protected function getAmount(SaleableInterface $saleableItem) { return $this->weeeHelper->getAmount($saleableItem); }
/** * Get weee amount * * @return float */ protected function getWeeeTaxAmount() { $product = $this->getSaleableItem(); return $this->weeeHelper->getAmount($product); }
public function testGetAmount() { $this->product->expects($this->any())->method('hasData')->will($this->returnValue(false)); $this->product->expects($this->any())->method('getData')->will($this->returnValue(11.26)); $this->assertEquals('11.26', $this->helperData->getAmount($this->product)); }
/** * Obtain amount * * @param SaleableInterface $saleableItem * @return float */ protected function getAmount(SaleableInterface $saleableItem) { $weeeAmount = $this->weeeHelper->getAmount($saleableItem); $weeeAmount = $this->priceCurrency->convertAndRound($weeeAmount); return $weeeAmount; }