Question

I'm new to Magento and trying to edit the success page on 1.9x

All I want is to add payment details for some payment methods. If the customer selects BANK TRANSFER, I want My_Block to be shown on the success page (these are the bank transfer details 'My bank account #00000') I would like to apply the same to maybe other payments.

I've tried many statements, but nothing so far.

    <?php if(payment === 'banktransfer'): ?>
    <p><?php echo $this->__('My_block') ?></p>
<?php elseif(payment === 'checkmo'): ?>
    <p><?php echo $this->__('My_block2');?></p> 
<?php else(payment === 'purchaseorder'): ?>
    <p><?php echo $this->__('My_block3') ?></p>
<?php endif; ?>

Any ideas on how to achieve this? Thank you for your help

Was it helpful?

Solution

First you need to get payment method for the last order. You can use below code on success.phtml

<?php if ($this->getOrderId()):?>
    <div class="bank_detail">
    <?php $orderId = $this->getOrderId(); ?>
    <?php $order = Mage::getModel("sales/order")->loadByIncrementId($orderId); //load order by increment id?>
    <?php $paymentCode = $order->getPayment()->getMethod(); ?>

       <?php if ($paymentCode=='checkmo') { 
           echo "whatever you want!";
       } //you can also check for other payment method?>

   </div>
<?php endif;?>

Explanation: First we load order by its increment id and get payment method from the loaded order. We can check for payment method echo content based on method.

Hope above will help.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top