0

I'm trying to get a better understanding of Magento module development and I've ran into an issue I can't seem to figure out.

I've built a custom module that allows users to pick a desired delivery date (via this article). Now it works fine for the most part, but I want the desired deliverydate to show up on the succespage. Now the module-tutorial covers how to get the date on order-pages, but I can't figure out why it won't show on the succes page.

The class in Block/Display/Deliverydate.php

class CustomModule_DeliveryTime_Block_Display_Deliverydate extends Mage_Core_Block_Template
{
    public function __construct()
    {
        $this->setTemplate('custommodule_deliverytime/sales/view_delivery_date.phtml');     
    }

    public function displayDeliveryDate()
    {
        $displayDate = false;

        if($this->getOrder()->getDesiredDeliveryDate() != NULL)
            $displayDate = true;

        return $displayDate;
    }

    public function getDisplayDeliveryDate()
    {
        return $this->getOrder()->getDisplayFormattedDeliveryDate();
    }

    public function getOrder()
    {
        return Mage::registry('current_order');
    }
}

The layout in the modules layout custommodule_deliverytime.xml layout

<?xml version="1.0"?>
<layout version="0.1.0">   

    -- Above here are similar references to sales_order_ blocks which do work --

    <checkout_onepage_success>
        <reference name="root">
            <block type="custommodule_deliverytime/display_deliverydate" after='-'></block>
        </reference>
    </checkout_onepage_success>
</layout>

The error report

Invalid method Mage_Checkout_Block_Onepage_Success::displayDeliveryDate(Array())
"#0 /usr/share/nginx/html/app/design/frontend/Company/MyTheme/template/checkout/success.phtml(219): Varien_Object->__call('displayDelivery...', Array)

I have a feeling I'm just missing something obvious, but I can't figure it out. As the class extends the Mage_Core_Block_Template, I would figure I could just call the block if stated in XML right?

Update: The config.xml of the module

    <?xml version="1.0"?>
    <config>
        <modules>
            <CustomModule_DeliveryTime>
                <version>0.1.0</version>
            </CustomModule_DeliveryTime>
        </modules>
        <default>
            <carriers>
                <custommodulecarrier>
                    <active>1</active>
                    <show_delivery_date>1</show_delivery_date>
                    <model>custommodule_deliverytime/carrier_custommodule</model>
                    <title>custommodule Carrier</title>
                    <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
                    <sallowspecific>1</sallowspecific>
                    <specificcountry>NL</specificcountry>
                    <showmethod>0</showmethod>
                    <sort_order>100</sort_order>
                </custommodulecarrier>
            </carriers>
        </default>
        <global>
            <helpers>
                <custommodule_deliverytime>
                    <class>custommodule_DeliveryTime_Helper</class>
                </custommodule_deliverytime>
            </helpers>
            <models>
                <custommodule_deliverytime>
                    <class>custommodule_DeliveryTime_Model</class>
                </custommodule_deliverytime>
                <checkout>
                    <rewrite>
                        <type_onepage>custommodule_DeliveryTime_Model_Checkout_Onepage</type_onepage>
                    </rewrite>
                </checkout>
                <sales>
                    <rewrite>
                        <order>custommodule_DeliveryTime_Model_Sales_Order</order>
                    </rewrite>
                </sales>
            </models>
            <blocks>
                <custommodule_deliverytime>
                    <class>custommodule_DeliveryTime_Block</class>
                </custommodule_deliverytime>
                <checkout>
                    <rewrite>
                        <onepage_progress>custommodule_DeliveryTime_Block_Onepage_Progress</onepage_progress>
                    </rewrite>
                </checkout>
            </blocks>
            <resources>
                <custommoduledeliverytime_setup>
                    <setup>
                        <module>custommodule_DeliveryTime</module>
                        <class>custommodule_deliverytime/resource_setup</class>
                    </setup>
                    <connection>
                        <use>core_setup</use>
                    </connection>
                </custommoduledeliverytime_setup>
            </resources>
            <events>
                <checkout_controller_onepage_save_shipping_method>
                    <observers>
                        <save_date>
                            <type>singleton</type>
                            <class>custommodule_deliverytime/observer</class>
                            <method>saveDesiredDeliveryTime</method>
                        </save_date>
                    </observers>
                </checkout_controller_onepage_save_shipping_method>
                <sales_convert_order_to_quote>
                    <observers>
                        <copy_delivery_date>
                            <type>singleton</type>
                            <class>custommodule_deliverytime/observer</class>
                            <method>copyDesiredDeliveryTimeToQuote</method>                        
                        </copy_delivery_date>
                    </observers>
                </sales_convert_order_to_quote>
                <adminhtml_sales_order_create_process_data>
                    <observers>
                        <update_order_creation_model>
                            <type>singleton</type>
                            <class>custommodule_deliverytime/observer</class>
                            <method>updateOrderCreationQuoteWithDeliveryDate</method>                        
                        </update_order_creation_model>
                    </observers>            
                </adminhtml_sales_order_create_process_data>
            </events>
            <fieldsets>
                <sales_convert_quote_address>
                    <desired_delivery_date>
                        <to_order>*</to_order>
                    </desired_delivery_date>
                </sales_convert_quote_address>
            </fieldsets>
        </global>
        <frontend>
            <layout>
                <updates>
                    <custommodule_deliverytime>
                        <file>custommodule_deliverytime.xml</file>
                    </custommodule_deliverytime>
                </updates>
            </layout>
            <routers>
                <deliverytime>
                    <use>standard</use>
                    <args>
                        <module>custommodule_DeliveryTime</module>
                        <frontName>deliverytime</frontName>
                    </args>
                </deliverytime>
            </routers>
        </frontend>
        <adminhtml>
            <layout>
                <updates>
                    <custommodule_deliverytime>
                        <file>custommodule_deliverytime.xml</file>
                    </custommodule_deliverytime>
                </updates>
            </layout>
        </adminhtml>
    </config>
  • Show your config.xml – Sohel Rana Oct 11 '17 at 15:54
  • It's running on PHP7.0, I've updated the question to include config.xml – Alex Timmer Oct 11 '17 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.