title: Magento howto fetch / change / overwrite the totals.phtml calculation?
body: <p>i had added a product that is calculated by two attributes and uses a own calculated price.
  the problem is that i had to rewrite the grandtotal and subtotal calculation... for example with overwritting the stuff. </p>
  
  <p>i hope here @stackoverflow is a magento guru that had solved my problem :-)</p>
  
  <p>i had changed the /app/design/frontend/default/gutlauf/template/checkout/cart/item/<strong>default.phtml</strong> where the layout of the cart items is done. </p>
  
  <p>but now i have a problem with /app/design/frontend/default/gutlauf/template/checkout/cart/<strong>totals.phtml</strong></p>
  
  <pre><code>&lt;table id="shopping-cart-totals-table"&gt;
      &lt;col /&gt;
      &lt;col width="1" /&gt;
      &lt;tfoot&gt;
          &lt;?php echo $this-&gt;renderTotals('footer'); ?&gt;
      &lt;/tfoot&gt;
      &lt;tbody&gt;
          &lt;?php echo $this-&gt;renderTotals(); ?&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>how can i get my own calculation ? 
  i figured out that the blocks</p>
  
  <p>tax/checkout_grandtotal 
  tax/checkout_subtotal
  tax/checkout_tax</p>
  
  <p>for example /app/design/frontend/default/gutlauf/template/tax/checkout/grandtotal.phtml</p>
  
  <pre><code>&lt;?php echo $this-&gt;helper('checkout')-&gt;formatPrice($this-&gt;getTotal()-&gt;getValue()) ?&gt;
  </code></pre>
  
  <p>according to the source code file there is a mentation of "Mage_Tax_Block_Checkout_Grandtotal"</p>
  
  <p>i looked at /app/code/core/Mage/Tax/Block/Checkout/Grandtotal.php commented some lines out... but nothing changed...</p>
  
  <p>i hope someone could explain to me where the shopping-cart calculation is "hidden", i need a foreach where the totals are build. </p>
  
  <p>i also looked at /app/code/core/Mage/Checkout/Block/Cart/<strong>Totals.php</strong></p>
  
  <p>i found the renderTotal ... no nowhere the solution of getting the foreach loop of the items, where i wanna use something like </p>
  
  <pre><code>            $productIds = array(); 
              $productIds[] = $_item['product_id'];
  
              $products = Mage::getModel('catalog/product')-&gt;getCollection() 
              -&gt;addAttributeToSelect('gl_special') 
              -&gt;addMinimalPrice() 
              -&gt;addStoreFilter() 
              -&gt;addIdFilter($productIds);
  
              $product = $products-&gt;getItemById($_item['product_id']);
              #print_r($product);
              $bBerechnet = $product-&gt;getData('gl_special');
  
  
  $childProducts = Mage::getModel('catalog/product_type_configurable')-&gt;getUsedProducts(null, $product);
  </code></pre>
  
  <p>to get the simple products which i load with </p>
  
  <pre><code>public function renderTotal($total, $area = null, $colspan = 1)
  {
      $code = $total-&gt;getCode();
  
      if ($total-&gt;getAs()) {
          $code = $total-&gt;getAs();
      }
      return $this-&gt;_getTotalRenderer($code)
          -&gt;setTotal($total)
          -&gt;setColspan($colspan)
          -&gt;setRenderingArea(is_null($area) ? -1 : $area)
          -&gt;toHtml();
  }
  </code></pre>