1

I need to add 2 custom blocks, one on the cart page (below the totals) and one on the checkout complete page. I've searched the net and can find no information on how I can do this. These blocks will contain custom js and need to interact with a custom model. I know how to write the modules required but I'm stuck with the XML and where I should place the templates/layout.

Can someone please give me a very short example (the equivalent of a 'hello world' that displays a block on the cart page)?

7ochem
7,61516 gold badges54 silver badges82 bronze badges
asked Jun 24, 2015 at 8:37

2 Answers 2

2

I think it will help you:

<checkout_cart_index>
 <reference name="head">
 <action method="addJs"><script>new.js</script></action>
 </reference>
 <block type="core/template" name="new" as="new" template="new.phtml" after="checkout.cart.totals" />
</checkout_cart_index>

Just put this short code into your custom layout XML.

answered Jun 24, 2015 at 9:06
2

Better idea define a new layout file from you custom module config.xml file .

<frontend>
 <layout>
 <updates>
 <custommodule>
 <file>custommodule.xml</file>
 </custommodule>
 </updates>
 </layout>
</frontend>

Then you need put this custommodule.xml file at app/design/frontend/YourPackage/YourTemplate/layout/

Now,you can add your template file (.phtml) using Page handler

We know that checkout cart page handler is checkout_cart_index and checkout success page is checkout_onepage_success.

on custommodule.xml.you need put this code:

<?xml version="1.0"?>
<layout version="0.1.0">
<checkout_cart_index>
 <reference name="content">
 <block type="core/template" name="Giveaname" as="GiveAliasename" template="YourPathlocation" />
 </reference> 
</checkout_cart_index>
<checkout_onepage_success>
 <reference name="content">
 <block type="core/template" name="Giveaname" as="GiveAliasename" template="YourPathlocationofTempkay" />
 </reference> 
</checkout_onepage_success>
</layout> 

The advantage of custom layout file is if module disable then the template is not works.

answered Jun 24, 2015 at 9:42
1
  • Thank you @Amit that looks like what I was looking for. I'll give it a try this morning and let you know how it went. Commented Jun 25, 2015 at 6:32

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.