示例#1
0
 /**
  * Get Tax Adjustments for configurable product
  *
  * @param \Magento\ConfigurableProduct\Pricing\Price\AttributePrice $attribute
  * @param array $result
  * @return array
  */
 public function afterPrepareAdjustmentConfig(\Magento\ConfigurableProduct\Pricing\Price\AttributePrice $attribute, array $result)
 {
     $product = $result['product'];
     $productClassId = $product->getTaxClassId();
     $defaultValue = $this->taxCalculationService->getDefaultCalculatedRate($productClassId, $result['customerId']);
     $result['defaultTax'] = $defaultValue + $result['defaultTax'];
     $currentTax = $this->taxCalculationService->getCalculatedRate($productClassId, $result['customerId']);
     $result['currentTax'] = $currentTax + $result['currentTax'];
     $adjustment = $product->getPriceInfo()->getAdjustment(\Magento\Tax\Pricing\Adjustment::ADJUSTMENT_CODE);
     $result['includeTax'] = $adjustment->isIncludedInBasePrice();
     $result['showIncludeTax'] = $this->taxHelper->displayPriceIncludingTax();
     $result['showBothPrices'] = $this->taxHelper->displayBothPrices();
     return $result;
 }
 /**
  * Modify the bundle config for the front end to resemble the tax included price when tax included prices
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->taxData->displayPriceIncludingTax()) {
         /** @var \Magento\Catalog\Model\Product $product */
         $product = $this->registry->registry('current_product');
         if ($product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
             $priceConfigObj = $observer->getData('configObj');
             try {
                 $priceConfig = $this->recurConfigAndUpdatePrice($priceConfigObj->getConfig(), 'prices');
                 $priceConfigObj->setConfig($priceConfig);
             } catch (\Exception $e) {
                 return $this;
             }
         }
     }
     return $this;
 }
示例#3
0
 /**
  * Should be displayed price including tax
  *
  * @return bool
  */
 public function displayPriceIncludingTax()
 {
     return $this->taxHelper->displayPriceIncludingTax();
 }
示例#4
0
 /**
  * Define if adjustment is included in display price
  *
  * @return bool
  */
 public function isIncludedInDisplayPrice()
 {
     return $this->taxHelper->displayPriceIncludingTax() || $this->taxHelper->displayBothPrices();
 }