1

I'm trying to get all tax rates I set up in my store my custom plugin, I'm using Magento 2.

I found that in db all tax rates are stored in tax_calculation_rate, but I didn't find a method to get all data from this.

Thank you for any help

1 Answer 1

3

By using the \Magento\Tax\Model\Calculation\Rate you can get a list of all the Tax Rates.

$getAllTaxRates = $this->taxRatesModel->getCollection()->getData();

foreach ($getAllTaxRates as $tax) {
    $taxid = $tax['tax_calculation_rate_id'];
    $taxCode = $tax["code"];
    $taxRate = $tax["rate"];

}

where taxRatesModel is an object of Magento\Tax\Model\Calculation\Rate class.

I hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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