Add an icon to shipping quotes in osCommerce

By | July 25, 2008

This is a super simple little modification that you can use to draw attention to your preferred method of shipping…

What we are going to do is add an icon to the “flat rate” quote, so that instead of looking like this:

It will look like this:

Step 1: Make your icon

This is easy enough – just make or acquire an icon. In the example above I used a “star” image, but you could use any image you wish.

Step 2: Upload your icon

The icon you made should be uploaded into your “icons” directory which is inside your “images” directory. It’s important to remember what you called the icon – I called mine star.jpg

Step 3: Code changes

Open up /includes/modules/shipping/flat.php and find this line of code:

[php]$this->icon = ”;[/php]

Change it to:

[php]$this->icon = DIR_WS_ICONS . ‘name_of_your_file’;[/php]

In my example, I had to change it to:

[php]$this->icon = DIR_WS_ICONS . ‘star.jpg’;[/php]

Save the file and upload. All being well, your image should now show. Easy as 123.

A little explanation of the line of code…

[php]$this->icon = DIR_WS_ICONS . ‘star.jpg’;[/php]

We are simply telling the software to look inside DIR_WS_ICONS (/images/icons/) for a file called star.jpg – and assign the image to $this->icon

Later on in the flat.php file, $this->icon is used to show the image…

[php]if (tep_not_null($this->icon)) $this->quotes[‘icon’] = tep_image($this->icon, $this->title);[/php]

Which might not make any sense to you, but that doesn’t matter. All you need to know is that if you did everything correctly, your image file will show up.

You can make this same change to any of your shipping methods – eg, you might use “Royal Mail Special Delivery” so you might want the SD logo. Have fun!

4 thoughts on “Add an icon to shipping quotes in osCommerce

  1. cassie

    This is a neat idea.
    Thanks again for the wonderful ideas and how to do them 🙂

  2. Gary Post author

    Cassie – thanks for your kind words 🙂

  3. Donna

    Excellent stuff!
    How can this be applied to the Payment Methods as well? (checkout_payment.php)

  4. Gary Post author

    Donna – the payment modules don’t have this functionality built in like the shipping modeules do, so this would need to be custom coded. You could try to take the $this->icon code from one of the shipping modules and apply to the payment module. If done correctly, it should work OK…

Leave a Reply

Your email address will not be published.