Checkout Layout – Adding a Block in

checkoutlayout

I am trying to add a block to <checkout_cart_index> after name="checkout.cart.totals" I have managed to add my block after the content area.

But I would like to add it immediately after "grand total". After reading this page I tried this

<checkout_cart_index>
    <reference name="content">
        <block type="mdeprojects_discount/remainder" name="mdeprojects.remainder" template="discount/remainder.phtml" after="-" name="checkout.cart" />
    </reference>
</checkout_cart_index>

Which gives me an error (name="checkout.cart.totals" gives the same error)

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 21: parser error : Attribute name redefined

A another attempt I made was

<checkout_cart_index>
    <reference name="content">
        <block type="mdeprojects_discount/remainder" name="mdeprojects.remainder" template="discount/remainder.phtml" after="checkout.cart.totals" />
    </reference>
</checkout_cart_index>

this still displays the block after the content area.

How do I add my block after "grand total" and why won't my method work?

Best Answer

Naming the block checkout.cart will cause a conflict because the parent block also has this name.

To add the block in the place you want, after the totals use the following XML

<checkout_cart_index>
    <reference name="checkout.cart">
        <block type="mdeprojects_discount/remainder" name="mdeprojects.remainder" as="mdeprojects.remainder" template="discount/remainder.phtml" />
    </reference>
</checkout_cart_index>

Then check the file template/checkout/cart.phtml on line 151. Here you can see <?php echo $this->getChildHtml('totals'); ?>. Place the following code on the next line:

<?php echo $this->getChildHtml('mdeprojects.remainder'); ?>