0

1.7.0.2 CE

I want to provide distinct instructions for the Bank Transfer Payment Method dependent/conditional on the Customers Billing Address Country.

If customer billing address country is AU then use 'Instructions AU' else use 'Instructions USA'

I believe the file that handles the instructions is app/design/frontend/base/default/template/payment/info/banktransfer.phtml

<?php
/**
 * @see Mage_Payment_Block_Info
 */
?>
<p><?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?></p>
<?php if ($this->getInstructions()): ?>
<table>
    <tbody>
        <tr>
            <td><?php echo nl2br($this->getInstructions()) ?></td>
        </tr>
    </tbody>
</table>
<?php endif; ?>

Ideally the instructions could be injected from a Static Block

1

In magento,Payment methods instructions does not taken from CMS static block.

It is basically taken from instructions field of each payment method setting (admin>System>Configuration>Sales>Payment Methods>Select payment method).

For banktransfer payment method,it is taken from admin>System>Configuration>Sales>Payment Methods>Banktransfer Instruction fields

For your case,you want to sperate instructions basis billing country and instructions is manage from cms static block then you can try below solution:

  1. create two Cms static blocks
  2. rewrite Mage_Payment_Block_Form_Banktransfer block class bcoz getInstructions() function the instruction will show

Code:

<?php class [ModuleNameSpace]_[ModuleName]_Block_Form_Banktransfer extends Mage_Payment_Block_Form_Banktransfer{
        public function getInstructions()
        {       if(!Mage::app()->getStore()->isAdmin():         $checkout = Mage::getSingleton('checkout/session')->getQuote();         $billAddress = $checkout->getBillingAddress();      $countryId = $billAddress->getCountryId();      if($countryId=='AU'){           $block = Mage::getModel('cms/block')
                    ->setStoreId(Mage::app()->getStore()->getId())
                    ->load('AU_blockId');
                     $helper = Mage::helper('cms');
                    $processor = $helper->getBlockTemplateProcessor();
                    $html = $processor->filter($block->getContent());           $this->_instructions = $html;       }else{

                $block = Mage::getModel('cms/block')
                    ->setStoreId(Mage::app()->getStore()->getId())
                    ->load('blockId_US');
                     $helper = Mage::helper('cms');
                    $processor = $helper->getBlockTemplateProcessor();
                    $html = $processor->filter($block->getContent());           $this->_instructions = $html;       }       endif;
            if (is_null($this->_instructions)) {
                $this->_instructions = $this->getMethod()->getInstructions();
            }
            return $this->_instructions;
        }    }
  • Thank you for tidying up the code in your reply. I ended up using a different approach using multiple bank transfer payment methods github.com/webbuddy/MobWeb_MultipleBankTransferPaymentMethods which in conjunction with other modules allows me to also enable/disable the various bank transfer methods on a per customer group basis. I will however have a look at your solution as an alternative approach. – webbuddy Jun 24 '16 at 23:40

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.