About Club osCommerce

Showcasing osCommerce…the good, the bad and the ugly!

Follow osc_pro on Twitter

Add an icon to shipping quotes in osCommerce

Written By Gary on Jul 25 2008 · Comments (4) Follow osc_pro on Twitter

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:
  1. $this->icon = '';

Change it to:

PHP:
  1. $this->icon = DIR_WS_ICONS . 'name_of_your_file';

In my example, I had to change it to:

PHP:
  1. $this->icon = DIR_WS_ICONS . 'star.jpg';

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:
  1. $this->icon = DIR_WS_ICONS . 'star.jpg';

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:
  1. if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);

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!


Buy Gary A Beer?
Buying me a "beer" helps me to keep my contributions updated and keep this blog alive - and you get a link from my homepage to your site. Cheers!


4 Comments

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

    Comment by cassie — July 30, 2008 @ 6:11 am


  2. Cassie – thanks for your kind words :)

    Comment by Gary — July 30, 2008 @ 9:57 pm


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

    Comment by Donna — July 30, 2009 @ 2:01 am


  4. 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…

    Comment by Gary — August 3, 2009 @ 8:42 am


Leave a comment

RSS feed for comments on this post · TrackBack URL

Hot 100 osCommerce Shops

View the osCommerce HOT 100These are the best looking, most exceptional osCommerce Stores as voted for by you.

New to osCommerce - get inspiration from these beautiful shops. Reckon your site has what it takes to become a member of the HOT 100? Submit it!