Magento 1 - How to get relevant 'tax_calculation_rate_id' from order items The Next CEO of Stack OverflowHow to get all order items using sales_order_grid_collection_load_before in magentoHow to Get tax Percent of orderGet order items inside the orderHow to get subtotal from order items collection in magento 1.9.2 community editionGet Order Items from product sku and customer emailGet all relevant data from the customer/customer tableHow to get Credit Memos items for an orderAdd tax percentage to order emailSQL to get order items straight from the database?How to get tax amount of product in magento 2?

Why isn't acceleration always zero whenever velocity is zero, such as the moment a ball bounces off a wall?

Does increasing your ability score affect your main stat?

Is it my responsibility to learn a new technology in my own time my employer wants to implement?

Why, when going from special to general relativity, do we just replace partial derivatives with covariant derivatives?

Where do students learn to solve polynomial equations these days?

Solving system of ODEs with extra parameter

Is it convenient to ask the journal's editor for two additional days to complete a review?

Why does standard notation not preserve intervals (visually)

Is a distribution that is normal, but highly skewed considered Gaussian?

Why doesn't UK go for the same deal Japan has with EU to resolve Brexit?

Can MTA send mail via a relay without being told so?

Running a General Election and the European Elections together

How to invert MapIndexed on a ragged structure? How to construct a tree from rules?

When you upcast Blindness/Deafness, do all targets suffer the same effect?

I want to delete every two lines after 3rd lines in file contain very large number of lines :

I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin

How do I align (1) and (2)?

Proper way to express "He disappeared them"

Is it okay to majorly distort historical facts while writing a fiction story?

Grabbing quick drinks

Does Germany produce more waste than the US?

Why is the US ranked as #45 in Press Freedom ratings, despite its extremely permissive free speech laws?

Why is information "lost" when it got into a black hole?

Make solar eclipses exceedingly rare, but still have new moons



Magento 1 - How to get relevant 'tax_calculation_rate_id' from order items



The Next CEO of Stack OverflowHow to get all order items using sales_order_grid_collection_load_before in magentoHow to Get tax Percent of orderGet order items inside the orderHow to get subtotal from order items collection in magento 1.9.2 community editionGet Order Items from product sku and customer emailGet all relevant data from the customer/customer tableHow to get Credit Memos items for an orderAdd tax percentage to order emailSQL to get order items straight from the database?How to get tax amount of product in magento 2?










1















I'm trying to get 'tax_calculation_rate_id' by iterating through ordered products.



The following code works ok, but the problem arises when there are multiple ids assigned to the same percentage values (e.g. "VAT exempt rate" at 0% and "EC Sales rate" at 0%)



Is there a better way to get the rate ids calculated?



Thank you for your help!



// $line_item and $address come as arguments 

$store = Mage::app()->getStore();
$product_class= Mage::getModel('catalog/product')
->loadByAttribute('sku',$line_item->getSku())
->getTaxClassId();
$tax_model = Mage::getSingleton('tax/calculation');
$request = $tax_model->getRateRequest($address, null, null, $store);
$percent = $tax_model->getRate($request->setProductClassId($product_class));

$rates = Mage::getModel("tax/calculation_rate")
->getCollection()
->addFieldToFilter('rate', array('eq'=>$percent));
foreach ($rates as $rate)

$mage_rate_id = $rate->getTaxCalculationRateId();
// if more than 1 rate exits it obviously picks the last one










share|improve this question




























    1















    I'm trying to get 'tax_calculation_rate_id' by iterating through ordered products.



    The following code works ok, but the problem arises when there are multiple ids assigned to the same percentage values (e.g. "VAT exempt rate" at 0% and "EC Sales rate" at 0%)



    Is there a better way to get the rate ids calculated?



    Thank you for your help!



    // $line_item and $address come as arguments 

    $store = Mage::app()->getStore();
    $product_class= Mage::getModel('catalog/product')
    ->loadByAttribute('sku',$line_item->getSku())
    ->getTaxClassId();
    $tax_model = Mage::getSingleton('tax/calculation');
    $request = $tax_model->getRateRequest($address, null, null, $store);
    $percent = $tax_model->getRate($request->setProductClassId($product_class));

    $rates = Mage::getModel("tax/calculation_rate")
    ->getCollection()
    ->addFieldToFilter('rate', array('eq'=>$percent));
    foreach ($rates as $rate)

    $mage_rate_id = $rate->getTaxCalculationRateId();
    // if more than 1 rate exits it obviously picks the last one










    share|improve this question


























      1












      1








      1








      I'm trying to get 'tax_calculation_rate_id' by iterating through ordered products.



      The following code works ok, but the problem arises when there are multiple ids assigned to the same percentage values (e.g. "VAT exempt rate" at 0% and "EC Sales rate" at 0%)



      Is there a better way to get the rate ids calculated?



      Thank you for your help!



      // $line_item and $address come as arguments 

      $store = Mage::app()->getStore();
      $product_class= Mage::getModel('catalog/product')
      ->loadByAttribute('sku',$line_item->getSku())
      ->getTaxClassId();
      $tax_model = Mage::getSingleton('tax/calculation');
      $request = $tax_model->getRateRequest($address, null, null, $store);
      $percent = $tax_model->getRate($request->setProductClassId($product_class));

      $rates = Mage::getModel("tax/calculation_rate")
      ->getCollection()
      ->addFieldToFilter('rate', array('eq'=>$percent));
      foreach ($rates as $rate)

      $mage_rate_id = $rate->getTaxCalculationRateId();
      // if more than 1 rate exits it obviously picks the last one










      share|improve this question
















      I'm trying to get 'tax_calculation_rate_id' by iterating through ordered products.



      The following code works ok, but the problem arises when there are multiple ids assigned to the same percentage values (e.g. "VAT exempt rate" at 0% and "EC Sales rate" at 0%)



      Is there a better way to get the rate ids calculated?



      Thank you for your help!



      // $line_item and $address come as arguments 

      $store = Mage::app()->getStore();
      $product_class= Mage::getModel('catalog/product')
      ->loadByAttribute('sku',$line_item->getSku())
      ->getTaxClassId();
      $tax_model = Mage::getSingleton('tax/calculation');
      $request = $tax_model->getRateRequest($address, null, null, $store);
      $percent = $tax_model->getRate($request->setProductClassId($product_class));

      $rates = Mage::getModel("tax/calculation_rate")
      ->getCollection()
      ->addFieldToFilter('rate', array('eq'=>$percent));
      foreach ($rates as $rate)

      $mage_rate_id = $rate->getTaxCalculationRateId();
      // if more than 1 rate exits it obviously picks the last one







      magento-1.9 taxes






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited yesterday









      Rakesh Donga

      2,258316




      2,258316










      asked 2 days ago









      MikeMike

      184




      184




















          1 Answer
          1






          active

          oldest

          votes


















          1














          I guess, you will need to get the dedicated tax rates not only by percentage but also by code.
          I would say you can to call $tax_model->getAppliedRates($request->setProductClassId($product_class)) instead of $tax_model->getRate($request->setProductClassId($product_class)).
          With that call you will get an array with all rates - but as far as I see the tax_calculation_rate_id is not in this array (for what ever reason).
          Therfore you will need to get the rates with an additional call to $tax_model->getRates($ruleId).



          I suppose the code for that would look like this - but I haven't tested it:



          $tax_model = Mage::getSingleton('tax/calculation');
          $request = $tax_model->getRateRequest($address, null, null, $store);
          $appliedRates = $tax_model->getAppliedRates($request->setProductClassId($product_class));

          foreach ($appliedRates as $appliedRate)
          foreach ($appliedRate['rates'] as $oneRate)
          //returns an array of all applied rate ids
          $rates = $tax_model->getRates($oneRate['rule_id']);




          Anyway, I quess alternatively you can get all the data you need by using the following 3 tables: sales_order_tax_item, sales_order_tax and tax_calculation_rate.
          Each order item has entries for each applied tax rate in sales_order_tax_item, therefore you just need to consider the corresponding rows in that table.
          This should work, if you have unique codes for your tax rates.



          //assuming your parameter $line_item is an order item you can load the entries 
          //for that order item from sales_order_tax_item table
          $taxItemCollection = Mage::getModel('tax/sales_order_tax_item')
          ->getCollection()
          ->addFieldToFilter('item_id', array('eq'=>$line_item->getId()));

          //iterate through the collection items and load the corresponding sales_order_tax entry
          //and based on that the corresponding tax_calculation_rate entry
          foreach ($taxItemCollection as $taxItem)
          $tax = Mage::getModel('tax/sales_order_tax')->load($taxItem->getTaxId());
          $rate = Mage::getModel("tax/calculation_rate")-loadByCode($tax->getCode());
          $mage_rate_id = $rate->getTaxCalculationRateId();






          share|improve this answer























          • Thank you for your reply. They both work but only if the tax rate is more than 0.

            – Mike
            yesterday












          • I might need to implement an if statement and add an algorithm to handle 0% cases. Any suggestions?

            – Mike
            yesterday











          • That's strange. The first approach $tax_model->getAppliedRates() just joins the tables tax_calculation, tax_calculation_rule, tax_calculation_rate and gets the corresponding data whitout taking care of the percentage of the rate. I would suggest to dump the array $appliedRates and see what's inside. If you don't see the data there, check the generated SQL in Mage_Tax_Model_Resource_Calculation::getCalculationProcess()

            – HelgeB
            20 hours ago











          • You are right. $appliedRates is empty if there's no relevant tax rule set up. Thank you every so much!

            – Mike
            2 hours ago












          • Out of curiosity, in what cases there are more than one [rates] in the $appliedRates array? If there's always one rate wouldn't that be easier to access it by $appliedRates[0]['rates'][0]['rule_id'], or by $appliedRates[0]['id'] and then addFieldToFilter('tax_calculation_rate_id', array('eq'=>$id)); ?

            – Mike
            2 hours ago











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f267875%2fmagento-1-how-to-get-relevant-tax-calculation-rate-id-from-order-items%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          I guess, you will need to get the dedicated tax rates not only by percentage but also by code.
          I would say you can to call $tax_model->getAppliedRates($request->setProductClassId($product_class)) instead of $tax_model->getRate($request->setProductClassId($product_class)).
          With that call you will get an array with all rates - but as far as I see the tax_calculation_rate_id is not in this array (for what ever reason).
          Therfore you will need to get the rates with an additional call to $tax_model->getRates($ruleId).



          I suppose the code for that would look like this - but I haven't tested it:



          $tax_model = Mage::getSingleton('tax/calculation');
          $request = $tax_model->getRateRequest($address, null, null, $store);
          $appliedRates = $tax_model->getAppliedRates($request->setProductClassId($product_class));

          foreach ($appliedRates as $appliedRate)
          foreach ($appliedRate['rates'] as $oneRate)
          //returns an array of all applied rate ids
          $rates = $tax_model->getRates($oneRate['rule_id']);




          Anyway, I quess alternatively you can get all the data you need by using the following 3 tables: sales_order_tax_item, sales_order_tax and tax_calculation_rate.
          Each order item has entries for each applied tax rate in sales_order_tax_item, therefore you just need to consider the corresponding rows in that table.
          This should work, if you have unique codes for your tax rates.



          //assuming your parameter $line_item is an order item you can load the entries 
          //for that order item from sales_order_tax_item table
          $taxItemCollection = Mage::getModel('tax/sales_order_tax_item')
          ->getCollection()
          ->addFieldToFilter('item_id', array('eq'=>$line_item->getId()));

          //iterate through the collection items and load the corresponding sales_order_tax entry
          //and based on that the corresponding tax_calculation_rate entry
          foreach ($taxItemCollection as $taxItem)
          $tax = Mage::getModel('tax/sales_order_tax')->load($taxItem->getTaxId());
          $rate = Mage::getModel("tax/calculation_rate")-loadByCode($tax->getCode());
          $mage_rate_id = $rate->getTaxCalculationRateId();






          share|improve this answer























          • Thank you for your reply. They both work but only if the tax rate is more than 0.

            – Mike
            yesterday












          • I might need to implement an if statement and add an algorithm to handle 0% cases. Any suggestions?

            – Mike
            yesterday











          • That's strange. The first approach $tax_model->getAppliedRates() just joins the tables tax_calculation, tax_calculation_rule, tax_calculation_rate and gets the corresponding data whitout taking care of the percentage of the rate. I would suggest to dump the array $appliedRates and see what's inside. If you don't see the data there, check the generated SQL in Mage_Tax_Model_Resource_Calculation::getCalculationProcess()

            – HelgeB
            20 hours ago











          • You are right. $appliedRates is empty if there's no relevant tax rule set up. Thank you every so much!

            – Mike
            2 hours ago












          • Out of curiosity, in what cases there are more than one [rates] in the $appliedRates array? If there's always one rate wouldn't that be easier to access it by $appliedRates[0]['rates'][0]['rule_id'], or by $appliedRates[0]['id'] and then addFieldToFilter('tax_calculation_rate_id', array('eq'=>$id)); ?

            – Mike
            2 hours ago















          1














          I guess, you will need to get the dedicated tax rates not only by percentage but also by code.
          I would say you can to call $tax_model->getAppliedRates($request->setProductClassId($product_class)) instead of $tax_model->getRate($request->setProductClassId($product_class)).
          With that call you will get an array with all rates - but as far as I see the tax_calculation_rate_id is not in this array (for what ever reason).
          Therfore you will need to get the rates with an additional call to $tax_model->getRates($ruleId).



          I suppose the code for that would look like this - but I haven't tested it:



          $tax_model = Mage::getSingleton('tax/calculation');
          $request = $tax_model->getRateRequest($address, null, null, $store);
          $appliedRates = $tax_model->getAppliedRates($request->setProductClassId($product_class));

          foreach ($appliedRates as $appliedRate)
          foreach ($appliedRate['rates'] as $oneRate)
          //returns an array of all applied rate ids
          $rates = $tax_model->getRates($oneRate['rule_id']);




          Anyway, I quess alternatively you can get all the data you need by using the following 3 tables: sales_order_tax_item, sales_order_tax and tax_calculation_rate.
          Each order item has entries for each applied tax rate in sales_order_tax_item, therefore you just need to consider the corresponding rows in that table.
          This should work, if you have unique codes for your tax rates.



          //assuming your parameter $line_item is an order item you can load the entries 
          //for that order item from sales_order_tax_item table
          $taxItemCollection = Mage::getModel('tax/sales_order_tax_item')
          ->getCollection()
          ->addFieldToFilter('item_id', array('eq'=>$line_item->getId()));

          //iterate through the collection items and load the corresponding sales_order_tax entry
          //and based on that the corresponding tax_calculation_rate entry
          foreach ($taxItemCollection as $taxItem)
          $tax = Mage::getModel('tax/sales_order_tax')->load($taxItem->getTaxId());
          $rate = Mage::getModel("tax/calculation_rate")-loadByCode($tax->getCode());
          $mage_rate_id = $rate->getTaxCalculationRateId();






          share|improve this answer























          • Thank you for your reply. They both work but only if the tax rate is more than 0.

            – Mike
            yesterday












          • I might need to implement an if statement and add an algorithm to handle 0% cases. Any suggestions?

            – Mike
            yesterday











          • That's strange. The first approach $tax_model->getAppliedRates() just joins the tables tax_calculation, tax_calculation_rule, tax_calculation_rate and gets the corresponding data whitout taking care of the percentage of the rate. I would suggest to dump the array $appliedRates and see what's inside. If you don't see the data there, check the generated SQL in Mage_Tax_Model_Resource_Calculation::getCalculationProcess()

            – HelgeB
            20 hours ago











          • You are right. $appliedRates is empty if there's no relevant tax rule set up. Thank you every so much!

            – Mike
            2 hours ago












          • Out of curiosity, in what cases there are more than one [rates] in the $appliedRates array? If there's always one rate wouldn't that be easier to access it by $appliedRates[0]['rates'][0]['rule_id'], or by $appliedRates[0]['id'] and then addFieldToFilter('tax_calculation_rate_id', array('eq'=>$id)); ?

            – Mike
            2 hours ago













          1












          1








          1







          I guess, you will need to get the dedicated tax rates not only by percentage but also by code.
          I would say you can to call $tax_model->getAppliedRates($request->setProductClassId($product_class)) instead of $tax_model->getRate($request->setProductClassId($product_class)).
          With that call you will get an array with all rates - but as far as I see the tax_calculation_rate_id is not in this array (for what ever reason).
          Therfore you will need to get the rates with an additional call to $tax_model->getRates($ruleId).



          I suppose the code for that would look like this - but I haven't tested it:



          $tax_model = Mage::getSingleton('tax/calculation');
          $request = $tax_model->getRateRequest($address, null, null, $store);
          $appliedRates = $tax_model->getAppliedRates($request->setProductClassId($product_class));

          foreach ($appliedRates as $appliedRate)
          foreach ($appliedRate['rates'] as $oneRate)
          //returns an array of all applied rate ids
          $rates = $tax_model->getRates($oneRate['rule_id']);




          Anyway, I quess alternatively you can get all the data you need by using the following 3 tables: sales_order_tax_item, sales_order_tax and tax_calculation_rate.
          Each order item has entries for each applied tax rate in sales_order_tax_item, therefore you just need to consider the corresponding rows in that table.
          This should work, if you have unique codes for your tax rates.



          //assuming your parameter $line_item is an order item you can load the entries 
          //for that order item from sales_order_tax_item table
          $taxItemCollection = Mage::getModel('tax/sales_order_tax_item')
          ->getCollection()
          ->addFieldToFilter('item_id', array('eq'=>$line_item->getId()));

          //iterate through the collection items and load the corresponding sales_order_tax entry
          //and based on that the corresponding tax_calculation_rate entry
          foreach ($taxItemCollection as $taxItem)
          $tax = Mage::getModel('tax/sales_order_tax')->load($taxItem->getTaxId());
          $rate = Mage::getModel("tax/calculation_rate")-loadByCode($tax->getCode());
          $mage_rate_id = $rate->getTaxCalculationRateId();






          share|improve this answer













          I guess, you will need to get the dedicated tax rates not only by percentage but also by code.
          I would say you can to call $tax_model->getAppliedRates($request->setProductClassId($product_class)) instead of $tax_model->getRate($request->setProductClassId($product_class)).
          With that call you will get an array with all rates - but as far as I see the tax_calculation_rate_id is not in this array (for what ever reason).
          Therfore you will need to get the rates with an additional call to $tax_model->getRates($ruleId).



          I suppose the code for that would look like this - but I haven't tested it:



          $tax_model = Mage::getSingleton('tax/calculation');
          $request = $tax_model->getRateRequest($address, null, null, $store);
          $appliedRates = $tax_model->getAppliedRates($request->setProductClassId($product_class));

          foreach ($appliedRates as $appliedRate)
          foreach ($appliedRate['rates'] as $oneRate)
          //returns an array of all applied rate ids
          $rates = $tax_model->getRates($oneRate['rule_id']);




          Anyway, I quess alternatively you can get all the data you need by using the following 3 tables: sales_order_tax_item, sales_order_tax and tax_calculation_rate.
          Each order item has entries for each applied tax rate in sales_order_tax_item, therefore you just need to consider the corresponding rows in that table.
          This should work, if you have unique codes for your tax rates.



          //assuming your parameter $line_item is an order item you can load the entries 
          //for that order item from sales_order_tax_item table
          $taxItemCollection = Mage::getModel('tax/sales_order_tax_item')
          ->getCollection()
          ->addFieldToFilter('item_id', array('eq'=>$line_item->getId()));

          //iterate through the collection items and load the corresponding sales_order_tax entry
          //and based on that the corresponding tax_calculation_rate entry
          foreach ($taxItemCollection as $taxItem)
          $tax = Mage::getModel('tax/sales_order_tax')->load($taxItem->getTaxId());
          $rate = Mage::getModel("tax/calculation_rate")-loadByCode($tax->getCode());
          $mage_rate_id = $rate->getTaxCalculationRateId();







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered yesterday









          HelgeBHelgeB

          3,0281322




          3,0281322












          • Thank you for your reply. They both work but only if the tax rate is more than 0.

            – Mike
            yesterday












          • I might need to implement an if statement and add an algorithm to handle 0% cases. Any suggestions?

            – Mike
            yesterday











          • That's strange. The first approach $tax_model->getAppliedRates() just joins the tables tax_calculation, tax_calculation_rule, tax_calculation_rate and gets the corresponding data whitout taking care of the percentage of the rate. I would suggest to dump the array $appliedRates and see what's inside. If you don't see the data there, check the generated SQL in Mage_Tax_Model_Resource_Calculation::getCalculationProcess()

            – HelgeB
            20 hours ago











          • You are right. $appliedRates is empty if there's no relevant tax rule set up. Thank you every so much!

            – Mike
            2 hours ago












          • Out of curiosity, in what cases there are more than one [rates] in the $appliedRates array? If there's always one rate wouldn't that be easier to access it by $appliedRates[0]['rates'][0]['rule_id'], or by $appliedRates[0]['id'] and then addFieldToFilter('tax_calculation_rate_id', array('eq'=>$id)); ?

            – Mike
            2 hours ago

















          • Thank you for your reply. They both work but only if the tax rate is more than 0.

            – Mike
            yesterday












          • I might need to implement an if statement and add an algorithm to handle 0% cases. Any suggestions?

            – Mike
            yesterday











          • That's strange. The first approach $tax_model->getAppliedRates() just joins the tables tax_calculation, tax_calculation_rule, tax_calculation_rate and gets the corresponding data whitout taking care of the percentage of the rate. I would suggest to dump the array $appliedRates and see what's inside. If you don't see the data there, check the generated SQL in Mage_Tax_Model_Resource_Calculation::getCalculationProcess()

            – HelgeB
            20 hours ago











          • You are right. $appliedRates is empty if there's no relevant tax rule set up. Thank you every so much!

            – Mike
            2 hours ago












          • Out of curiosity, in what cases there are more than one [rates] in the $appliedRates array? If there's always one rate wouldn't that be easier to access it by $appliedRates[0]['rates'][0]['rule_id'], or by $appliedRates[0]['id'] and then addFieldToFilter('tax_calculation_rate_id', array('eq'=>$id)); ?

            – Mike
            2 hours ago
















          Thank you for your reply. They both work but only if the tax rate is more than 0.

          – Mike
          yesterday






          Thank you for your reply. They both work but only if the tax rate is more than 0.

          – Mike
          yesterday














          I might need to implement an if statement and add an algorithm to handle 0% cases. Any suggestions?

          – Mike
          yesterday





          I might need to implement an if statement and add an algorithm to handle 0% cases. Any suggestions?

          – Mike
          yesterday













          That's strange. The first approach $tax_model->getAppliedRates() just joins the tables tax_calculation, tax_calculation_rule, tax_calculation_rate and gets the corresponding data whitout taking care of the percentage of the rate. I would suggest to dump the array $appliedRates and see what's inside. If you don't see the data there, check the generated SQL in Mage_Tax_Model_Resource_Calculation::getCalculationProcess()

          – HelgeB
          20 hours ago





          That's strange. The first approach $tax_model->getAppliedRates() just joins the tables tax_calculation, tax_calculation_rule, tax_calculation_rate and gets the corresponding data whitout taking care of the percentage of the rate. I would suggest to dump the array $appliedRates and see what's inside. If you don't see the data there, check the generated SQL in Mage_Tax_Model_Resource_Calculation::getCalculationProcess()

          – HelgeB
          20 hours ago













          You are right. $appliedRates is empty if there's no relevant tax rule set up. Thank you every so much!

          – Mike
          2 hours ago






          You are right. $appliedRates is empty if there's no relevant tax rule set up. Thank you every so much!

          – Mike
          2 hours ago














          Out of curiosity, in what cases there are more than one [rates] in the $appliedRates array? If there's always one rate wouldn't that be easier to access it by $appliedRates[0]['rates'][0]['rule_id'], or by $appliedRates[0]['id'] and then addFieldToFilter('tax_calculation_rate_id', array('eq'=>$id)); ?

          – Mike
          2 hours ago





          Out of curiosity, in what cases there are more than one [rates] in the $appliedRates array? If there's always one rate wouldn't that be easier to access it by $appliedRates[0]['rates'][0]['rule_id'], or by $appliedRates[0]['id'] and then addFieldToFilter('tax_calculation_rate_id', array('eq'=>$id)); ?

          – Mike
          2 hours ago

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f267875%2fmagento-1-how-to-get-relevant-tax-calculation-rate-id-from-order-items%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Sum ergo cogito? 1 nng

          三茅街道4182Guuntc Dn precexpngmageondP