示例#1
0
 /**
  * @param PriceBox $subject
  * @return string
  */
 private function getTaxRateIds(PriceBox $subject)
 {
     $rateIds = [];
     $customerSession = $this->customerSession;
     $billingAddress = $customerSession->getDefaultTaxBillingAddress();
     $shippingAddress = $customerSession->getDefaultTaxShippingAddress();
     $customerTaxClassId = $customerSession->getCustomerTaxClassId();
     if (!empty($billingAddress)) {
         $billingAddress = new \Magento\Framework\DataObject($billingAddress);
     }
     if (!empty($shippingAddress)) {
         $shippingAddress = new \Magento\Framework\DataObject($shippingAddress);
     }
     if (!empty($billingAddress) || !empty($shippingAddress)) {
         $rateRequest = $this->getTaxCalculation()->getRateRequest($billingAddress, $shippingAddress, $customerTaxClassId, $this->scopeResolver->getScope()->getId(), $this->customerSession->getCustomerId());
         $rateRequest->setProductClassId($subject->getSaleableItem()->getTaxClassId());
         $rateIds = $this->getTaxCalculation()->getResource()->getRateIds($rateRequest);
     }
     return implode('_', $rateIds);
 }
示例#2
0
 /**
  * @return string
  */
 protected function _toHtml()
 {
     $result = parent::_toHtml();
     try {
         /** @var MsrpPrice $msrpPriceType */
         $msrpPriceType = $this->getSaleableItem()->getPriceInfo()->getPrice('msrp_price');
     } catch (\InvalidArgumentException $e) {
         $this->_logger->logException($e);
         return $this->wrapResult($result);
     }
     //Renders MAP price in case it is enabled
     if ($msrpPriceType->canApplyMsrp($this->getSaleableItem())) {
         /** @var BasePriceBox $msrpBlock */
         $msrpBlock = $this->rendererPool->createPriceRender(MsrpPrice::PRICE_CODE, $this->getSaleableItem(), ['real_price_html' => $result]);
         $result = $msrpBlock->toHtml();
     }
     return $this->wrapResult($result);
 }
 /**
  * @return string
  */
 protected function _toHtml()
 {
     if (!$this->getSaleableItem() || $this->getSaleableItem()->getCanShowPrice() === false) {
         return '';
     }
     $result = parent::_toHtml();
     try {
         /** @var MsrpPrice $msrpPriceType */
         $msrpPriceType = $this->getSaleableItem()->getPriceInfo()->getPrice('msrp_price');
     } catch (\InvalidArgumentException $e) {
         $this->_logger->critical($e);
         return $this->wrapResult($result);
     }
     //Renders MSRP in case it is enabled
     $product = $this->getSaleableItem();
     if ($msrpPriceType->canApplyMsrp($product) && $msrpPriceType->isMinimalPriceLessMsrp($product)) {
         /** @var BasePriceBox $msrpBlock */
         $msrpBlock = $this->rendererPool->createPriceRender(MsrpPrice::PRICE_CODE, $this->getSaleableItem(), ['real_price_html' => $result, 'zone' => $this->getZone()]);
         $result = $msrpBlock->toHtml();
     }
     return $this->wrapResult($result);
 }
示例#4
0
 /**
  * @param Context $context
  * @param Product $saleableItem
  * @param PriceInterface $price
  * @param RendererPool $rendererPool
  * @param Data $jsonHelper
  * @param Random $mathRandom
  * @param array $data
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function __construct(Context $context, Product $saleableItem, PriceInterface $price, RendererPool $rendererPool, Data $jsonHelper, Random $mathRandom, array $data = [])
 {
     $this->jsonHelper = $jsonHelper;
     $this->mathRandom = $mathRandom;
     parent::__construct($context, $saleableItem, $price, $rendererPool);
 }
 public function testGetRendererPool()
 {
     $this->assertEquals($this->rendererPool, $this->model->getRendererPool());
 }
示例#6
0
 /**
  * {@inheritdoc}
  *
  * @return array
  */
 public function getCacheKeyInfo()
 {
     $cacheKeys = parent::getCacheKeyInfo();
     $cacheKeys['display_minimal_price'] = $this->getDisplayMinimalPrice();
     return $cacheKeys;
 }