1

I want to get tax rate (percentage) on product-view page. Following code only shows text of tax:

$currentProduct->getAttributeText('tax_class_id')

Thanks for help! martn

6

I achieved getting tax rates by using \Magento\Tax\Api\TaxCalculationInterface:

$rate = $this->taxCalculation
              ->getCalculatedRate($productTaxClassId, $customerId, $storeId);
  • hi @Lukas,can we get the tax amout from product id in magento2? – jafar pinjar May 14 at 9:37
0

You can get tax rate by:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

$taxCalculation = $objectManager->create( 'Magento\Tax\Model\Calculation\Rate' )->load( <tax_rate_id> , 'tax_calculation_rate_id' );

$rate = $taxCalculation->getRate();

where <tax_rate_id> get from Tax Zones and Rates admin screen /tax/rate/ , or you can get it programmatically with TaxRuleModel

  • Load is deprecated, is there another way to do this? – Pathfinder Jan 11 at 21:20
-1

Try this

$currentProduct->getTaxClassId();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.