2

I want to add some custom information below the payment method list in the "Payment Information" tab.

I have noticed the following method call in app/design/frontend/base/default/template/checkout/onepage/payment/methods.phtml:

<?php echo $this->getChildChildHtml('additional'); ?>

This would be perfect for me as it would allow me to add my custom block without modifying any templates.

However, looking at the XML layout for that specific template, I see no reference to that additional block (app/design/frontend/base/default/layout/checkout.xml):

<checkout_onepage_index translate="label">
    ...
        <block type="checkout/onepage_payment_methods" name="checkout.payment.methods" as="methods" template="checkout/onepage/payment/methods.phtml">
            <action method="setMethodFormTemplate"><method>purchaseorder</method><template>payment/form/purchaseorder.phtml</template></action>
        </block>
    ...
</checkout_onepage_index>

Since the method call in the methods.phtml template file uses the getChildChildHtml (and not getChildHtml) method, I can't simply add a block with the name additional to my custom XML layout. Instead I have to do this:

<checkout_onepage_index translate="label">
    <reference name="checkout.payment.methods">
        <block type="core/text_list" name="checkout.payment.methods.additional" as="additional" translate="label">
            <block type="cms/block" name="my.custom.block" as="custom"><action method="setBlockId"><block_id>test</block_id></action></block>
        </block>
     </reference>
</checkout_onepage_index>

This works, because I have created a text list block with the name additional and have added my custom block as a child to that block.

But now I feel like this is not the perfect solution. If another XML layout had to use that additional block, my definition would get overwritten, right?

  • Hi @louis-b, this is very interesting and I would like to do something similar. Where did you put your part of the code? Was it in your own checkout.xml or somewhere else? Do you have to do something else to enable it to be visible? – Alex Dec 17 '17 at 22:24
  • 1
    It doesn't really matter which layout file you put the code in, as long as its being loaded by Magento. As far as I can tell/remember what you can see above should be all that is required for the custom block to appear. Of course you'll also have to create the Static Block with an identifier of "my.custom.block" (or whatever you want to name it, just also update the XML above). – Louis B. Dec 18 '17 at 10:35
2

So as far as I can see this is maybe something that Magento missed off. As in the older version and also in Mage1.9 in the default checkout.xml the additional block is missing for the payments. Though in the rwd xml file it is there.

<block type="core/template" name="checkout.onepage.payment.additional" as="additional" />

I think that what you have done to add in the block is perfect for your needs.

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.