In Magento 2 how we can check from order object that what is the settings for the tax either its including or excluding. We can get the tax info generally by this function


but this function return the current setting for the tax, is there any method to check the setting from the order object ? So we can get the tax settings while the order created.

What if we save the settings while order creation ?


6 Answers 6


You must extend the Magento\Sales\Model\Order\Tax\Item class and add an extension attribute, like tax_actual_setting, which will store an actual value of the corresponding tax type setting. There is two types of tax items by default - product and shipping. Each one has own calculation setting in the store config. Based on that value you could determine in future which setting has been used. Anyway detect that value on the store without additional field & code is unavailable, because the Magento is not saving this setting out of the box (with an order).

The tables you may be interested in is:

  • sales_order_tax_item
  • sales_order_tax


  • Magento\Sales\Model\Order\Tax
  • Magento\Sales\Model\Order\Tax\Item
  • Magento\Sales\Model\ResourceModel\Order\Tax
  • Magento\Sales\Model\ResourceModel\Order\Tax\Item

The data is linked with an order using order_id field in the sales_order_tax table.


Tax rate is not based on order, but on order item, so you will need to check these:


  • For it you have to load orderitem object for it.

For invoice items you need to request the associated order item by calling


  • For it you have to load orderitem object for it..

To get the whole tax information of an order, you may use


, which returns the whole tax calculation result.


In the order object there is a method called getBaseSubtotalInclTax() . Can you check with this method and try to compare with default basetotal.

  • which default basetotal method ?
    – Mehar
    Commented Jan 1, 2020 at 15:26
  • In order object. Commented Jan 4, 2020 at 16:41

I know that the use of objectManager is not a good idea but this answer is for understanding If this is helpful then I'm going to post proper answer with correct dependency..!

Please check the below answer and let me know if it's helpful.


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

$ordersObj = $objectManager->create('Magento\Sales\Model\ResourceModel\Order\CollectionFactory')->create();
foreach($ordersObj as $orders)
 $incrementId = $orders->getData("increment_id");   
 $orderData = $objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($incrementId);
 $orderItems = $orderData->getAllItems();

  foreach ($orderItems as $item) {
   if($item->getTaxAmount() != ''){ // Here you can get all order data
      //Tax is applied
    //Tax is not applied  

  • $item->getTaxAmount() also return the value in case of exclusive tax settgins.
    – Mehar
    Commented Jan 7, 2020 at 10:43
  • @Mehar, No, it will not return the value in case of exclusive tax setting, If it will return value then error in your Tax Setting from admin side. Commented Jan 7, 2020 at 10:59

Something like this?

    public function pricesIncludeTax($order) {
        $store = $order->getStore();
        $pricesIncludeTax = $this->scopeConfig->
        return ($pricesIncludeTax == 1); 

That won't help you if you've changed the tax settings from inc to ex since the order was placed, but it will give you the price display settings for the store applicable to the order.


You can use below method to get full tax information about tax from order object


go get tax percent first you need to fetch order's items collection and then you can get tax percent using below method


  • $order->getFullTaxInfo() not returning any information.
    – Mehar
    Commented Jan 5, 2020 at 20:31

Your Answer

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

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