Magento – Textarea for comments in Checkout

checkoutlayoutmagento-1.9

I try to implement a modul, which adds a textarea at the end of the checkoutprocess in "Order Review", but the textarea is nowhere to be seen, when i enable the "Template Path Hints"-Debugoption, i can see that it load my customized .phtml file, but there isnt a textarea.

Setupscript works fine

"Terms and Conditions" are enabled

Module is enabled

Here is the code:

app/code/local/Practice/CheckoutComments/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Practice_CheckoutComments>
            <version>0.0.1</version>
        </Practice_CheckoutComments>
    </modules>

    <global>
        <resources>
            <checkoutcomments_setup>
                <setup>
                    <module>Practice_CheckoutComments</module>
                </setup>
            </checkoutcomments_setup>
        </resources>
        <models>
            <checkoutcomments>
                <class>Practice_CheckoutComments_Model</class>
                <resourceModel>checkoutcomments_resource</resourceModel>
            </checkoutcomments>

            <checkoutcomments_resource>
                <class>Practice_CheckoutComments_Model_Resource</class>
                <entities>
                    <comments_table>
                        <table>checkout_comments</table>
                    </comments_table>
                </entities>
            </checkoutcomments_resource>
        </models>
    </global>
    <frontend>
        <layout>
            <updates>
                <checkoutcomments>
                    <file>practice/checkoutcomments.xml</file>
                </checkoutcomments>
            </updates>
        </layout>
    </frontend>
</config>

app/design/frontend/base/default/layout/practice/checkoutcomments.xml

<?xml version="1.0" encoding="UTF-8"?>
<layout>
    <checkout_onepage_review translate="label">
        <reference name="checkout.onepage.agreements">
            <action method="setTemplate">
                <template>practice/checkoutcomments/onepage/comment-agreements.phtml
                </template>
            </action>
        </reference>
    </checkout_onepage_review>
</layout>

app/design/frontend/base/default/template/practice/checkoutcomments/onepage/comment-agreements.phtml

<!--  Start of CheckoutComments module code -->

<form action="" id="checkout-agreements" onsubmit="return false;">
        <ol class="checkout-agreements">
        <div>
            <br /><label for="checkoutcomments"><?php echo Mage::helper('core')->__('Add your Comment for this Order') ?></label>
            <textarea name="checkoutcomments" id="checkoutcomments"
                style="width: 450px; height: 100px;"></textarea>
        </div>

<?php if ($this->getAgreements()) : ?>
        <!-- End of CheckoutComment module -->


<?php foreach ($this->getAgreements() as $_a): ?>
    <li>
            <div class="agreement-content"
                <?php echo ($_a->getContentHeight() ? ' style="height:' . $_a->getContentHeight() . '"' : '')?>>
            <?php if ($_a->getIsHtml()):?>
                <?php echo $_a->getContent()?>
            <?php else:?>
                <?php echo nl2br($this->escapeHtml($_a->getContent()))?>
            <?php endif; ?>
        </div>
            <p class="agree">
                <input type="checkbox" id="agreement-<?php echo $_a->getId()?>"
                    name="agreement[<?php echo $_a->getId()?>]" value="1"
                    title="<?php echo $this->escapeHtml($_a->getCheckboxText()) ?>"
                    class="checkbox" /><label for="agreement-<?php echo $_a->getId()?>"><?php echo $_a->getIsHtml() ? $_a->getCheckboxText() : $this->escapeHtml($_a->getCheckboxText()) ?></label>
            </p>
        </li>
<?php endforeach ?>

<?php endif; ?>

</ol>

</form>

Best Answer

You want to know whether your layout.xml file is loaded:

  1. Turn on Developer mode
  2. make a typo in your layout.xml
  3. clear cache
  4. there should be an error. If there is no error, your layout.xml is not loaded

You want to know whether your template is set:

  1. Install xdebug
  2. check whether the setTemplate method is called on the right block

Make sure nothing else changes your template!

Related Topic