Tag Archives: osCommerce-based code

free smooth javascript scroller for the bestsellers scroll infobox

The HTML ‘marquee’ tag is used to make the product images scroll vertically in the bestsellers_scroll infobox. It works, but creates a choppy display (as this horizontal example of the tag shows):

Hello! This is an example of a horizontal marquee plus image marquee scroll effect using wordpress icon


The following code is for a vertical scroll effect that is much smoother. There are some user editable settings in the jscript file defining delay, speed and mouse over actions. Colours are set in the #marqueecontainer css script.

This is a fairly easy mod to do – 1 new file, 3 small modifications to existing files.

Create this new file from the code below: /includes/javascript/marquee.js

* Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.

var delayb4scroll=500 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?


var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''

function scrollmarquee(){
if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8))

function initializemarquee(){
if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll)

if (window.addEventListener)
window.addEventListener("load", initializemarquee, false)
else if (window.attachEvent)
window.attachEvent("onload", initializemarquee)
else if (document.getElementById)

Add this line into: /templates/your template/mainpage.tpl.php

Modify your file: templates/your template/boxes/best_sellers_scroll.php

$info_box_contents[] = array('align' => 'center',
                             'text' => '
' . $bestsellers_list . '
'); new $infobox_template($info_box_contents, true, true, $column_location);

Add this at the end of the file: template/your template/stylesheet.css

position: relative;
width: 200px; /*marquee width */
height: 100px; /*marquee height */
background-color: white;
overflow: hidden;
border: 1px solid orange;
padding: 2px;
padding-left: 4px;

Australian zone and tax settings

You can plug all the default zone and tax settings through the Admin but there’s an easier way. The sql snippets below can be run through phpMyAdmin which you can usually access through cPanel. Once in phpmyadmin, select the database you want to update and click on the Sql tab at the top of the page. Copy n paste the code below then Go. Once done, your Australian store will have all the tax and zone information needed for using various shipping and payment modules.

Note – the sqls below are for a store that is missing the data. Check your admin for these settings already (eg under Localizations >> Currencies for AUD; under Locations/Taxes >> Zones for Australian states. There’s no point readding them if they already exist.)

Australian Zones (States)

INSERT INTO zones (zone_id, zone_country_id, zone_code, zone_name) VALUES ('',13,'NSW','New South Wales');
INSERT INTO zones (zone_id, zone_country_id, zone_code, zone_name) VALUES ('',13,'VIC','Victoria');
INSERT INTO zones (zone_id, zone_country_id, zone_code, zone_name) VALUES ('',13,'QLD','Queensland');
INSERT INTO zones (zone_id, zone_country_id, zone_code, zone_name) VALUES ('',13,'NT','Northern Territory');
INSERT INTO zones (zone_id, zone_country_id, zone_code, zone_name) VALUES ('',13,'WA','Western Australia');
INSERT INTO zones (zone_id, zone_country_id, zone_code, zone_name) VALUES ('',13,'SA','South Australia');
INSERT INTO zones (zone_id, zone_country_id, zone_code, zone_name) VALUES ('',13,'TAS','Tasmania');
INSERT INTO zones (zone_id, zone_country_id, zone_code, zone_name) VALUES ('',13,'ACT','Australian Capital Territory');

Australia GST Setup

update tax_class set tax_class_title="GST" where tax_class_title = "Taxable Goods";
update tax_class set tax_class_description="The following types of products attract GST in Australia" where tax_class_title = "GST";
update tax_rates set tax_description = "GST" where tax_description = "FL TAX 7.0%";
update tax_rates set tax_rate = "10" where tax_description = "GST";

Australia Currency Setup

update currencies set code = "AUD" where code = "USD";
update currencies set title = "Australian Dollar" where code = "AUD";
update configuration set configuration_value = "AUD" where configuration_key = "DEFAULT_CURRENCY";
update configuration set configuration_value = "true" where configuration_key = "DISPLAY_PRICE_WITH_TAX";

Australia Tax Geo Zone Setup

insert into `geo_zones` (`geo_zone_id`,`geo_zone_name`,`geo_zone_description`) values (1,'Australia','');
insert into zones_to_geo_zones (zone_country_id, zone_id, geo_zone_id)
select countries_id as zone_country_id, 0 as zone_id, geo_zone_id
   from countries, geo_zones
   where countries_name = "Australia"
   and geo_zone_name = "Australia";

change number of records shown in admin

Problem: the number of orders displayed by default is a mere 20. You have to use a dropdown to see results 21-40.

Go to Admin > Configuration > Maximum Values and change the Search Results figure to something more useful, as shown in the screen below:

screenshot of cre loaded admin, configuration, max values, search results

The Search Results setting controls the number of results displayed on each page in several different areas of the Admin, including Countries listed, Customer accounts shown, products on Specials … handy to know about this well-hidden setting!

better rounding of prices including tax

The rounding function produces rounding errors of 1c in some cases – sure, no big deal, but why not get it right eh?

So after checking osCommerce I found a better rounding formula that might work for you too (esp on taxable products):

File : includes/functions/general.php

// Wrapper function for round()
  function tep_round($number, $precision) {
    if (strpos($number, '.') && (strlen(substr($number, strpos($number, '.')+1)) > $precision)) {
      $number = substr($number, 0, strpos($number, '.') + 1 + $precision + 1);

      if (substr($number, -1) >= 5) {
        if ($precision > 1) {
          $number = substr($number, 0, -1) + ('0.' . str_repeat(0, $precision-1) . '1');
        } elseif ($precision == 1) {
          $number = substr($number, 0, -1) + 0.1;
        } else {
          $number = substr($number, 0, -1) + 1;
      } else {
        $number = substr($number, 0, -1);

    return $number;

Replace with:

function tep_round($number, $round=2) {
   $tempd = $number*pow(10,$round);
   $tempd1 = round($tempd);
   $number = $tempd1/pow(10,$round);
   return $number;

how to change the width of the left column in Admin

The width of the Admin left column is controlled by the css below.

If the css width is removed, the column width will default to 200px as specified in admin/include/left-column.php.

File: admin/includes/stylesheet.css, line 262

.menu-container {
  background-color: #f8f8f8;
  width: ???px;  // default is 180px
  border-right: solid 2px #ccc;
  padding-top: 12px;
  padding-bottom: 12px;

Change the ???px value to the desired width in pixels.