How to update currency rates in OsCommerce store

A client of mine wanted to display product prices in US dollar, Canadian dollar, British pound and Australian dollar so that the customer could view prices in their own currencies. The default currency was set to Euro. Now anyone who has used Oscommerce or developed modules in it would know that this is quite a simple task and was not a lot of work. However the client wanted the currencies to be updated in real time.

I first browsed through the Oscommerce website add-on section and surely there were some good modules there for this purpose. However, after seeing some of the code which had been written in earlier versions of PHP I decided to write my own.

The rates were to be fetched from the European Central Bank website. The rates are updated on the website every couple of hours and people could use them to display the most recent rates to their customers. As the output was in XML I decided to use the SimpleXML object which allowed you to process the XML as an object in PHP.

The code fetches the currency rates and updates them in the currency table. You can even setup a cron job which can fetch the rates on a timely basis and update your database.

You can download the code from here

How to add and display banners in OsCommerce

One of my clients wanted to show banners on his OsCommerce website home page. He said that he wanted to display the hot selling products on his home page so that customers can go and buy them in the shortest time possible. Not only that he also wanted the facility to upload and change images as quickly as possible.

So I got down to implementing it on the website. Now, unlike Zencart, OsCommerce does not have default banner code on the home page due to which I had to dig a bit deeper. Finally I found the function which displays the banner and that is

<?php echo tep_display_banner('dynamic','BannerGroup'); ?>

where you can add the group name for your banner(s) in place of BannerGroup. dynamic tells the system to randomly select a banner from the BannerGroup and display it. This will help the client to create more than one banner in the same BannerGroup and the system will take care of the rest.

Hope the above helped