/** * @param \Magento\Framework\App\ActionInterface $subject * @param callable $proceed * @param \Magento\Framework\App\RequestInterface $request * @return mixed * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundDispatch(\Magento\Framework\App\ActionInterface $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request) { if (!$this->customerSession->isLoggedIn() || !$this->moduleManager->isEnabled('Magento_PageCache') || !$this->cacheConfig->isEnabled() || !$this->taxHelper->isCatalogPriceDisplayAffectedByTax()) { return $proceed($request); } $defaultBillingAddress = $this->customerSession->getDefaultTaxBillingAddress(); $defaultShippingAddress = $this->customerSession->getDefaultTaxShippingAddress(); $customerTaxClassId = $this->customerSession->getCustomerTaxClassId(); if (!empty($defaultBillingAddress) || !empty($defaultShippingAddress)) { $taxRates = $this->taxCalculation->getTaxRates($defaultBillingAddress, $defaultShippingAddress, $customerTaxClassId); $this->httpContext->setValue('tax_rates', $taxRates, 0); } return $proceed($request); }