2

I'm developing a custom payment method and I'd like it to show some info (related to the payment method) on the success page.

How can I do this?

I've tried appending the block to the checkout_onepage_success content but I got nothing but errors.

<checkout_onepage_success translate="label">
    <reference name="content">
        <reference name="checkout.success">
            <action method="setChild">
                <block type="checkbuy/success" name="checkbuy.success" template="checkbuy/success.phtml" />
            </action>
        </reference>
    </reference>
</checkout_onepage_success>

EDIT: I also tried using <action method="append"> but it caused big PHP errors.

EDIT 2: I need the block only to be shown when my payment method is selected, I don't want to override the standard success page if the client uses other payment method.

1

Pleas try this:

<checkout_onepage_success translate="label">
    <reference name="content">
        <reference name="checkout.success">
                <block type="checkbuy/success" name="checkbuy.success" template="checkbuy/success.phtml" />
        </reference>
    </reference>
</checkout_onepage_success>

Then on succcess.phtml call this child block by

<?php echo $this->getChildHtml(checkbuy.success) ;?>
  • It works!! Sadly I can't use this solution because the payment method is going to be a redistributable module so I can't edit success.phtml (which is part of magento core files). – ElectricSid Jul 1 '15 at 13:10
  • What is full path to success.phtml ? Is it located in frontend/base/default? If yes you can copy success.phtml to your current theme and edit it. Otherwise you can change template for checkout.success block: <reference name="checkout.success"> <action method="setTemplate"> <template>mymodule/mysuccess.phtml</template> </action> </reference> – Neklo.com Jul 1 '15 at 20:38
  • The full path to the success.phtml file is frontend/base/default/template/checkout/success.phtml But doesn't that solution show mysuccess.phtml for every payment method? I'd like it to be shown (if possible) only when you select my payment method. – ElectricSid Jul 2 '15 at 6:25
  • need copy the file to frontend/YourPackage/YourTheme/template/checkout/success.phtml – Amit Bera Jul 2 '15 at 6:26
  • That way it works, but Magento shows my version of success.phtml with every payment method. I need it only to appear when the client uses my module for payment. Thanks a lot for your comments, they're helping me a lot. :) – ElectricSid Jul 2 '15 at 8:28
0

I found it!!

I was overriding the layout to checkout_onepage_success and that was the reason my block was showing in every payment method. So I defined the layout just for my module's payment success page and called the standard onepage_success block for checkout and then my custom information block.

Here's my final layout file:

<checkbuy_payment_success translate="label">
    <reference name="root">
        <action method="setTemplate">
            <template>page/1column.phtml</template>
        </action>
    </reference>
    <reference name="content">
        <block type="checkout/onepage_success" name="checkout.success" template="checkout/success.phtml"/>
        <block type="checkbuy/success" name="checkbuy.success" />
    </reference>
</checkbuy_payment_success>

Your Answer

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

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