I have tried the below line of code
$_order->getTaxPercent(); to get the tax percentage from the order file.
But unable to get that.
I had get shipping details by using $_order->getShippingAddress();
Please suggest me to get the tax percentage
Hello @anand_v,
You will get tax amount $_order->getTaxAmount() for render tax data on order object.
Do you want tax percentage? So you have to calculate for it.
--
If my answer is useful, please Accept as Solution & give Kudos
In order details page, I have the tax percentage(VAT) for the products as 12%.
I need to use the tax percentage for other purpose.
How to get this by code?
Kindly suggest any solution for this.
Hello @anand_v
Tax percentage save into item wise so you need to get all items and you need to do that.
Hope it will be answer of your question
Hello @anand_v
Now, I can get it
Tax rate is not based on order, but on order item, so you will need to check these: $orderItem->getTaxPercent() - For it you have to load orderitem object for it.
For invoice items you need to request the associated order item by calling $invoiceItem->getOrderItem()->getTaxPercent() - For it you have to load orderitem object for it..
To get the whole tax information of an order, you may use $order->getFullTaxInfo();, which returns the whole tax calculation result.
--
If my answer is useful, please Accept as Solution & give Kudos
Hello @anand_v,
Please check below code you will get full result for i
<?php namespace Vendor\Module\Helper; use \Magento\Framework\App\Helper\Context; use \Magento\Sales\Api\Data\OrderInterface; use \Magento\Sales\Model\ResourceModel\Order\Tax\Item; class APIHelper extends \Magento\Framework\App\Helper\AbstractHelper { /** * @var \Magento\Sales\Model\ResourceModel\Order\Tax\Item */ protected $taxItem; public function __construct( Context $context, Item $taxItem ) { parent::__construct($context); $this->taxItem = $taxItem; } public function someMethod(OrderInterface $order) { $tax_items = $this->taxItem->getTaxItemsByOrderId($order->getId()); var_dump($tax_items); } }
--
If my answer is useful, please Accept as Solution & give Kudos
to get the tax percentage you have to first get the order items from order like :
$items = $order->getAllItems(); foreach($items as $item){ $taxpercentage = $item->getTaxPercent(); }