Create “Instruction” field in admin payment method:
Here am going to explain about how to add a new “Instruction” textfiled (or) textarea (whatever you want you can add it) in admin payment gateway module.When customer choose the payment gateway from frontend, the customer will get instruction detail which one entered from admin section.
Admin will set the any instruction from admin side for each payment gateway.It will show in frontend when customer click on any of the payment gateway checkbox.
Following are files we have to create or need to change:
app\code\local\Jute\MYMODULE\etc\system.xml
app\design\frontend\Jute\MyModule\template\payment\form\mymodule.phtml
app\code\local\Jute\MYMODULE\Block\Form\Mymodule.php
app\code\local\Jute\MYMODULE\Model\Standard.php
Step:
1. app\code\local\Jute\MYMODULE\etc\system.xml
add our custom filed type
Ex Code:
<instructions translate=”label”>
<label>Instructions</label>
<frontend_type>textarea</frontend_type>
<sort_order>16</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</instructions>
2. app\design\frontend\jute\mumodule\template\payment\form\mymodule.phtml
<?php if ($this->getInstructions()): ?>
<ul id=”payment_form_<?php echo $this->getMethodCode() ?>” style=”display:none;”>
<li>
<div>
<?php echo nl2br($this->getInstructions()) ?>
</div>
</li>
</ul>
<?php endif; ?>
3. app\code\local\Jute\MYMODULE\Block\Form\Mymodule.php
class MYMODULE extends Mage_Payment_Block_Form
{
protected $_instructions;
protected function _construct()
{
parent::_construct();
$this->setTemplate(‘payment/form/mymodule.phtml’);
}
public function getInstructions()
{
if (is_null($this->_instructions)) {
$this->_instructions = $this->getMethod()->getInstructions();
}
return $this->_instructions;
}
}
4. app\code\local\Jute\MYMODULE\Model\Standard.php
public function getInstructions()
{
return trim($this->getConfigData(‘instructions’));
}
Thanks a lot!
one more thing is
we have to set in model following variable
protected $_formBlockType = ‘pathToYourForm’;
Thanks…Ankit…