-2

i work on opencart 2.0.0.1 i have two payment method COD and one payment gateway,i want to add payment gateway logo and COD image in checkout's Step 5: Payment Method.

enter image description here

i want to add image code in checkout/payment_method.tpl here is code..

<?php if ($payment_methods) { ?>
<p><?php echo $text_payment_method; ?></p>
<?php foreach ($payment_methods as $payment_method) { ?>
<div class="radio">
  <label>
    <?php if ($payment_method['code'] == $code || !$code) 
 { ?>
    <?php $code = $payment_method['code']; ?>
  <input type="radio" name="payment_method" value="<?php echo $payment_method['code']; ?>" checked="checked" />
    <?php 
 } else 
 { ?>
    <input type="radio" name="payment_method" value="<?php echo $payment_method['code']; ?>" />
    <?php
 } ?>
 
    <?php echo $payment_method['title']; ?>
    <?php if ($payment_method['terms']) { ?>
    (<?php echo $payment_method['terms']; ?>)
    <?php } ?>
  </label>
</div>
<?php } ?>
<?php } ?>
amisha
  • 366
  • 1
  • 4
  • 15

2 Answers2

2

I just tested under 2.1.0.2 wich is basically the same structure. first navigate to /catalog/model/payment/cheque.php find:

'title'      => $this->language->get('text_title'),

and replace it with:

'title'      => $this->language->get('img_title') . $this->language->get('text_title'),

Then Navigate to /language/english/payment/cheque.php add this to the bottom:

$_['img_title']         = '<img src="' . HTTPS_SERVER . 'image/check.jpg" alt="Check" title="Check" /></a>';

Change the name/location of the image you wished to use between the ' and " in the above code. and also change the alt="" and title="" to current payment your working on ex. alt="COD" or alt="PayPal"......

This works with any payment that you add or is default in opencart (cod, paypal, bank wire, ect)

Don't forget make the image the size you want. hope this helps.

Finished Result

enter image description here

DSKONLINE
  • 55
  • 7
  • BTW this also works for shipping logos also just change the location from payment to shipping in the links above. – DSKONLINE Feb 26 '16 at 22:03
  • sir your answer is right but i need to add every payment method's image or logo – amisha Feb 27 '16 at 06:53
  • just repeat the process for each payment (cod.php, pp_express.php,bank_transfer.php) – DSKONLINE Feb 27 '16 at 19:23
  • This answer could be turned in to a ocmod which does not affect the core files. just be careful if you upgrade your changes will be over written. – DSKONLINE Feb 27 '16 at 20:40
1

i have a solution

you can check manually payment method code and add images in checkout/paymentmethod controller

if ($method) 
     {
      if($method['code']=="cod")
      {
       $method['image'] = "<img src='image/COD.jpg' style='width:200px; height:100px'/>";
      }
      else if($method['code']=="cheque")
      {
       $method['image'] = "<img src='image/payumoney.jpg' style='width:200px; height:100px'/>";
      }
      if ($recurring) {
       if (method_exists($this->{'model_payment_' . $result['code']}, 'recurringPayments') && $this->{'model_payment_' . $result['code']}->recurringPayments()) {
        $method_data[$result['code']] = $method;
       }
      } else {
       $method_data[$result['code']] = $method;
      }
      
      //$method_data[$result['image']] = "<img src='image/payumoney.jpg' style='width:50px; height:50px'/>";
     }

and also change in view

<div class="radio payment_style" id="parent<?=$counter?>" for="radio<?=$counter?>">
    <label>
   <?php if ($payment_method['code'] == $code || !$code) 
   { ?>
   <?php $code = $payment_method['code']; ?>
    <input id="radio<?=$counter?>" type="radio" name="payment_method" value="<?php echo $payment_method['code']; ?>" checked="checked" class="hide payment_radio" onclick="change_payment_method('<?=$counter?>')"/>
   <?php 
   } else 
   { ?>
    <input type="radio" id="radio<?=$counter?>" class="hide payment_radio" name="payment_method" value="<?php echo $payment_method['code'];  ?>" onclick="change_payment_method('<?=$counter?>')" />
   <?php
   } ?>
   
   <div class="radimg"><?php echo $payment_method['image']; ?> </div>
   <?php /* echo $payment_method['title']; */?>
   <?php if ($payment_method['terms']) { ?>
   (<?php echo $payment_method['terms']; ?>)
   <?php } ?>
    </label>
  </div>