0

i have some custom shipping methods which is made by different extensions like webshopapps matrixrate and etc... . i want to add an icon (.png file) to each carrier.

i know that shipment methods names are shown in frontend by this code:

   <?php foreach ($_shippingRateGroups as $code => $_rates): ?>
        <dt><?php echo $this->getCarrierName($code) ?></dt>

how to change this code to show some .png file for each method?

2 Answers 2

0

You could just use the $code as the basis for the filename. In the code below I have set it to pull the images from /media/shipicons. You would just need to name the image the same as the shipping code.

<?php foreach ($_shippingRateGroups as $code => $_rates): ?>
     <dt><img src="/media/shipicons/<?php echo $code; ?>.jpg" /><?php echo $this->getCarrierName($code) ?></dt>
2
  • i copied the code and i made a picture file named 'shippingRateGroups.jpg' in magento root/media/shipicons but the .jpg file won't load.
    – Moh3n
    Commented Jan 29, 2015 at 16:21
  • No, you'll want to use the $code variable. In this case it should be something like ups or usps. Then you would create your graphic in /media/shipicons/ups.jpg and /media/shipicons/usps.jpg. If you Inspect Element or view source on the shipping page then you'll see what $code is supposed to be. Commented Jan 29, 2015 at 16:34
0

1- Create this folder at \media\wysiwyg\icon\ and put your icons named after every shipping method code (e.g: flatrate.png)

2- Open: \app\design\frontend\base\default\template\checkout\onepage\shipping_method\available.phtml and find this code that print shipping method name:

<?php echo $this->escapeHtml($this->getCarrierName($code)) ?>

and add this code before that, it will print icon if it exists:

<?php
$icon_url = Mage::getBaseUrl('media').'/wysiwyg/icon/'.$code.'.png';
$icon_path = Mage::getBaseDir('media').'/wysiwyg/icon/'.$code.'.png';
if(file_exists($icon_path)){
    echo '<img src="'.$icon_url.'"/>';
}
?>

Your Answer

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

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