1

Payment information depends on shipping method

In Shipping Method when selected Standard Shipping 2-7 days then hide Cash On Delivery and vise versa

when shipping method is fixed then hide check money order if check stranded shipping then hide cash on delivery

i already add this code in \app\design\frontend\base\default\template\checkout\onepage\payment\method.phtm

getMethods(); $oneMethod = count($methods) __('No Payment Methods') ?> getCode(); if($_POST['shipping_method'] == 'flatrate_flatrate') { if($_code == 'checkmo') { continue; } } ?>

enter image description here enter image description here

1 Answer 1

1

credits : Elavarasan for link

In the link, they used different shipping and payment methods. you need to change the codes according to your requirements.

shipping_method => flatrate_flatrate
 paymet_method   => checkmo

As for I got, you trying to hide some payment methods based on shipping method. For this you don't need to observe things at all. Simply you can do this, just follow me,

Every methods(in one page check out) post the methods which are chosen to the next level. so you can get the shipping method which are chosen, in payment method level. Just print the post things in

app/design/frontend/base/default/template/checkout/onepage/payment/methods.phtml

in this add below one,

<?php print_r($_POST); ?>

So now you can get the shipping methods which are chosen previous step. And note it, so now, you can add just simple logic (if else) condition in same file for hiding payment,

For example here I want hide check / money order payment method, if shipping method is flat. Here the payment method code is checkmo. you can get payment method code by simply printing that variable like echo $_code = $_method->getCode(); in same file. so here just add simple if else ,

  <?php
    $methods = $this->getMethods();


    $oneMethod = count($methods) <= 1;
?>
<?php if (empty($methods)): ?>
    <dt>
        <?php echo $this->__('No Payment Methods') ?>
    </dt>
<?php else:
    foreach ($methods as $_method):
       echo  $_code = $_method->getCode();


if($_POST['shipping_method'] == 'flatrate_flatrate') {
if($_code == 'checkmo') {
    continue;
}
}
?>

Here,

 if($_POST['shipping_method'] == 'flatrate_flatrate') {
if($_code == 'checkmo') {
    continue;
}
}

checks the shipping method and skip the payment method which we don't want to display. That's it. Please comment here if you have any doubt.

Note:

 shipping_method => flatrate_flatrate
 paymet_method   => checkmo
6
  • Bro i apply as it but its not working when i check flat in payment method Check / Money order is still display
    – Danish Ali
    Sep 26, 2017 at 8:01
  • Bro is it possible when i select stranded shipping 2-3 days in shipping method then only Bank transfer display in payment method other payment method off
    – Danish Ali
    Sep 26, 2017 at 8:08
  • @DanishAli yes, you need to use the respective shipping & payment method codes and try...... Sep 26, 2017 at 9:06
  • Hello Sir (@Baby in Magento) i have applied as suggested by you but its not working sir kindly check 3 images still 1 month+ i am unable to solve it [1]: i.stack.imgur.com/HlI3F.png [2]: i.stack.imgur.com/EE4In.png [3]: i.stack.imgur.com/0r7mZ.png
    – Danish Ali
    Oct 13, 2017 at 10:49
  • @DanishAli please update the question with updated code & images...... Oct 13, 2017 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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