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

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

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

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

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?

  • For clarity, I would assume the simplexml error is due to the block having the name attribute defined twice, as opposed to the block having a name attribute value the same as its parent. – pspahn Dec 11 '13 at 20:59

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

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

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'); ?>
  • after attribute is really required ? Since he is calling directly block output into template. I mean, the new block will be where the getChildHtml is called nevertheless. – Niloct Dec 11 '13 at 16:18
  • You're right, it's not. Updated the answer. Thanks! – Sander Mangel Dec 11 '13 at 16:22
  • Thanks for your response, but it has not worked. I tried, then copied and pasted your code to make sure it was not a typo. – tony09uk Dec 11 '13 at 16:27
  • try using core/template as a type to see if it's an error in the block and make sure your template exists. Also turn of cache and compiling – Sander Mangel Dec 11 '13 at 16:29
  • 1
    No worries. Glad it works now. Always good to use template hints to check what phtml file you should modify and in what directory – Sander Mangel Dec 12 '13 at 11:04

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.