0

I need to add some complex information to 'one page checkout', in billing.phtml. As it requires a lot of php code I need to put it in a separate phtml file. How do I insert this file after billing form(address details)?

I've tried putting this code into custom .xml layout file:

<layout version="0.1.0">
 <checkout_onepage_index translate="label">
  <reference name="checkout.onepage">
   <block type="core/template" name="checkout.onepage.dealer" after="checkout.onepage.billing" template="checkoutfields/search.phtml" as="checkout_dealer_search" />
  </reference>
 </checkout_onepage_index>
</layout> 

and then calling this in username/persistent/checkout/onepage/billing.phtml (the one that was being used):

echo $this->getChildHtml('checkout_dealer_search'); 

but nothing was added under address details form. My search.phtml contains a test string.


Update

When I change reference in checkoutfields.xml to

<reference name="checkout.onepage.billing">

it doesn't work but when I paste my block into base layout file persistence.xml in

<checkout_onepage_index>
 <reference name="checkout.onepage.billing">

it works. I have a feeling that I am missing something simple. Do I have to register this custom xml file somehow(it's not a part of a module)?

0

2 Answers 2

2

try the following:

<layout version="0.1.0">
 <checkout_onepage_index translate="label">
  <reference name="checkout.onepage.billing">
   <block type="core/template" name="checkout.onepage.dealer" template="checkoutfields/search.phtml" as="checkout_dealer_search" />
  </reference>
 </checkout_onepage_index>
</layout>

and use echo $this->getChildHtml('checkout_dealer_search'); in the billing.phtml.

UPDATE:

if the checkoutfields.xml is not part of any module, you can create local.xml in the respected layout folder and move the code in it.

2
  • Thanks MTM. It nearly works. I've updated my question. Would you mind to take a look?
    – Alan
    Sep 30, 2014 at 9:39
  • if the checkoutfields.xml is not part of any module, you can create local.xml and move the code in it.
    – MTM
    Sep 30, 2014 at 9:42
0

I think, you need to put it inside the billing.phtml block, not the onepage block. You should change this. In this scenario $this->getParent()->getChildHtml('checkout_dealer_search') should work. But don'T do it this way. Order your blocks correct!

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.