0

In my cart page i am trying to alter the styles of total price displayed

frontend\base\default\template\checkout/cart/totals.phtml

frontend\base\default\template\tax/checkout/grandtotal.phtml

frontend\base\default\template\tax/checkout/subtotal.phtml

These templates displays the subtotal and grand total.

<tfoot>
            <?php echo $this->renderTotals('footer'); ?>
        </tfoot>
        <tbody>
            <?php echo $this->renderTotals(); ?>
        </tbody>

This is the default phtml. The <tfoot> appears on first followed by <tbody> but in browser the <tfoot> appears after <tbody> .

I was trying to modify the htmls for displaying this, but the pbm i facing is grand total appears above sub total.

How to make grand total appear after sub total?

2

So you've stumbled on one of the fun parts of Magento...

And by fun I mean it is very challenging to customize.

You'll want to look at: Mage_Checkout_Block_Cart_Totals

the "renderTotals(" function...

 $html = '';
        foreach($this->getTotals() as $total) {
            if ($total->getArea() != $area && $area != -1) {
                continue;
            }
            $html .= $this->renderTotal($total, $area, $colspan);
        }
        return $html;

The $this->getTotals() call returns and ordered array, so in order to change the order on the front end you need to add logic that Sorts the array before this foreach loop.

| improve this answer | |
1

It is HTML standard to show the table in this order:

table
    thead
    tbody (if any)
    tfoot

Therefore if you remove the <tfoot> (and <tbody>) it might fix your problem.

| improve this answer | |
  • It doesn't matter that tfoot is after tbody, it displays the same order. – inavas Dec 24 '13 at 11:33
  • Correct, tfoot is always shown after the tbody but if you remove the tbody and only left the <tr>s it should have the order in the HTML – Fabian Blechschmidt Dec 24 '13 at 23:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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