3

I would like to add a field in the checkout page for a custom payment method.

Actually because my method extends CC the form is automatically generated (I have no layout set) look at -> Mage_Checkout_Block_Onepage_Payment_Methods with getPaymentMethodFormHtml() function:

    public function getPaymentMethodFormHtml(Mage_Payment_Model_Method_Abstract $method)
{
     return $this->getChildHtml('payment.method.' . $method->getCode());
}

This is good however I would like to add a comment form ( only for this payment method ) using a custom layout: keep the current form and add an extra block with an text input field.

2 Answers 2

5

In your payment model, you should set protected $_formBlockType = 'foo/form'; class that derives from Mage_Payment_Model_Method_Cc and create a template/foo/form.phtml file. This allows you to write your own form file.

Then you need to override assignData($data) function (payment model) in order to save this extra field value in the $paymentInfo obj.

In case you will need to show that field in info as well you can do the same as above with $_infoBlockType variable.

1
  • right :) I just did it
    – Fra
    Commented Feb 6, 2013 at 16:11
0

Refer the following link

for doing it using a module created for it

this is the link

2
  • 2
    Welcome to magento.se and Thanks for the answer! To be sure, that this information is still available in a few months or years, please copy (rewrite) the most important informations from the blogpost here. Commented May 10, 2013 at 13:02
  • the link will stay, hopefully some more years to come. that's a lengthy process, which is why I provided the link.
    – Shathish
    Commented May 11, 2013 at 5:29

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.