I'm trying to add a custom order attribute, that the user can define on the checkout page just after the list of the payment methods and before the button continue.
I want to do things as clean as possible, so I created my own module.
Im struggling with something I thought it would be simple but I don't succeed to find a solution.
At the moment I only need to be able to display the template file in the following block .
Mage_Checkout_Block_Onepage_Payment
I created my template file which is only displaying a stupid text for the test app/design/defaut/defaut/template/mymodule/custom.phtml I know that there is no problem with this file while I used it on the index action of my module
I think the main issue is that I must not do properly the xml layout declaration.
Maybe you can help me
<?xml version="1.0"?>
<layout version="0.1.0">
<!-- this part is working well -->
<mymodule_index_index>
<reference name="content">
<block type="mymodule/mymodule" name="mymodule" template="mymodule/custom.phtml" />
</reference>
</mymodule_index_index>
<!-- this part is not working at all -->
<checkout_onepage_index>
<reference="checkout.onepage.payment" >
<block type="core/template" name="mymodule" template="mymodule/custom.phtml" />
</reference>
</checkout_onepage_index>
</layout>
Of course my module is well declared as the index method of my module is working. is it my reference tag which is not good ?
Thanks in advance, this layout organisation gives me headache,
Best,
Anselme
1 Answer 1
David Tay answered to me via stackoverflow , thanks to him I fixed my issues, it was due to two mains reasons
- Developer inatention
- In the block where I wanted to add my block I was supposed to echo it
Link to the answer https://stackoverflow.com/a/30067067/613123
Copy / Paste of the answer below:
As b.enoit.be noted, you forgot the name attribute. Besides that, you also need to echo out your block. This is your update:
<checkout_onepage_index>
<reference name="checkout.onepage.payment" >
<block type="core/template" name="mymodule" template="mymodule/custom.phtml" />
</reference>
</checkout_onepage_index>
Your block is declared as a child of checkout.onepage.payment, which also has another child block (checkout.payment.methods) and this block is echoed out in the checkout.onepage.payment template (app/design/frontend/base/default/template/checkout/onepage/payment.phtml):
<form action="" id="co-payment-form">
<fieldset>
<?php echo $this->getChildHtml('methods') ?>
</fieldset>
</form>
What you need to do is echo out your block some where in the checkout.onepage.payment block's template, such as:
<?php echo $this->getChildHtml('mymodule') ?>
Explore related questions
See similar questions with these tags.