How to rewrite one page checkout success block

We suppose create a new module, name is MyModule and NameSpace is Posixtech.

Step 1: Create a xml file inside this location app/etc/modules/Posixtech_MyModule.xml.

example :

<config>
	<modules>
		<Posixtech_MyModule>
			<active>true</active>
			<codePool>local</codePool>
		</Posixtech_MyModule>
	</modules>
</config>

Step 2: Create a config file inside this location app/code/local/Posixtech/MyModule/etc/config.xml
example :

<?xml version="1.0"?>
<config>
	<modules>
		<Posixtech_MyModule>
			<version>1.0.1</version>
		</Posixtech_MyModule>
	</modules>
    <frontend>
        <routers>
            <mymodule>
                <use>standard</use>
                <args>
                    <module>Posixtech_MyModule</module>
                    <frontName>mymodule</frontName>
                </args>
            </mymodule>
        </routers>
        <layout>
            <updates>
                <mymodule>
                    <file>mymodule.xml</file>
                </mymodule>
            </updates>
        </layout>
    </frontend>
    <global>
        <blocks>
            <mymodule>
                <class>Posixtech_MyModule_Block</class>
            </mymodule>
            <checkout>
                <rewrite>
                    <onepage_success>Posixtech_MyModule_Block_Onepage_Success</onepage_success>
                </rewrite>
            </checkout>
        </blocks>
    </global>
</config>

Step 3: Then we have to create this block (into our module) that should be exdends from Mage_Checkout_Block_Onepage_Success, inside the location app/code/local/Posixtech/MyModule/Block/Onepage/Success.php

example:
class Posixtech_MyModule_Block_Onepage_Success extends Mage_Checkout_Block_Onepage_Success
{
// Write your custom methods
// All parent’s methods also will work
}

Step 4: Create a new xml file for frontend and location is app/design/frontend/base/default/layout/mymodule.xml
example:

<?xml version="1.0"?>
<layout version="0.1.0">
    <checkout_onepage_success translate="label">
        <label>One Page Checkout Success</label>
        <reference name="root">
            <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
        </reference>
        <reference name="content">
            <reference name="checkout.success">
                <action method="setTemplate"><template>mymodule/success.phtml</template></action>
            </reference>
        </reference>
    </checkout_onepage_success>
</layout>

Step 5: Create a file inside this location app/design/frontend/base/default/template/mymodule/success.phtml

You can customize phtml file content without editing base file.

That’s it!

One thought on “How to rewrite one page checkout success block

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s