Category Archives: free code

free oscCommerce-based cart modifications, code and fixes that may help your store

USPS fix for November 2013 for oscommerce based carts

USPS, in an unannounced move last Friday 8th November, decided to change the way it supplied rates information via its servers to the many ecommerce carts around the global who request realtime USPS quotes. They changed the transfer-encoding to chunked. This is a more efficient way for this data to be transferred, so not really before time.

However it caught out a number of old usps modules which relied on an ever growing number of filters to clean up the rates data xml, because these scripts relied on the old http_client class which didn’t support dechunking this data cleanly.

For those modules that called upon curl this change would have made no difference, eg zencart, whose usps script uses curl primarily and only fallsback to http_client as a last resort.

Free code download I’ve modified the oscommerce usps USPS Rate V4 Intl Rate V2 module to check and use curl. This is written for Loaded Commerce 6.5 but can be modified for other version use.

 

how to install ajax country state selector

The address book feature of oscommerce-based carts is fairly weak in some areas. This modification and free code module will help in the new account creation area by changing the clunky ‘choose a country, type in a state’ method of the current carts* to one that uses ajax to pull a list of states from the database based on the selected country. And by default it will load the store’s country (s most traders do in fact sell mostly to their own country.)

(* In fact the default cart behaviour in oscommerce 2.2 and cre loaded is to make you GUESS the spelling of the state and then if you get it wrong it’ll throw an error and THEN show you a dropdown list of states from the database. Madness.)

Ajax Country State Selector
(cre loaded port, from oscommerce contribution country state selector by steve lionel)

Written for:
any version of cre loaded 6.2.x -> 6.5.x, but easy to convert for all osCommerce-based carts (including oscMax, zencart)

Video Demo:


What it does:

Ajax Country State Selector improves the address handling functions of the cart and makes it quicker and easier for customers to create and edit addresses, whether in their account or in the checkout. The store’s default country and any states of that country are loaded with the page. On change of country, any states associated with that country will be loaded too.

Ease of use:
Should know how to check and setup zones if missing from cart. Otherwise, nothing to do.

Limitations:
The code provided ONLY shows a modified create account page – there are several other address areas in the cart that would need to be edited if this functionality was required for all screens. However, if new customers can get their accounts setup correctly then some of the subsequent address issues may be avoided.

The other real possibility is that the ajax functionality fails. There can be many reasons for this, and may be caused by conflict with a highly modified template that already uses javascript extensively. NO GUARANTEES are provided with this script.

Experience needed to install:
Beginner – upload 3 files, edit 5 files.

Don’t want to install it yourself?
No problem – drop me an email and I can install it for you at a minimal price.

 

check for missing unused images on your server

IMAGE CHECK
(aka osCommerce contribution remove_unused_images)

Written for:
any version of cre loaded series 6 cart, but easy to convert for all osCommerce-based carts (including oscMax, zencart)

screenshot of image check
screenshot of image check

What it does:
Scans and lists all your image files, compares the ones requested by the database products and products_description tables with all of the image files on the server in the /images directory and subdirectories of /images (one level deep.) Then shows a list of any unused images (ie on the server but not being called by the database) with the option of shifting
these into /images/UNUSED.

Ease of use:
Moderate skill needed – you do need to manually set the configuration options in the /admin/image_check.php file. Instructions are included as comments in this file.

Risk from use:
None – no files are actually deleted, only shifted. Low chance of conflict with other store files.

Limitations:
1. When searching product_descriptions, it will only report on images already on the server NOT on the ones called by the database and missing from the server.
2. Will only search one subdirectory deep in the /images folder, so /images/flowers/pic1.jpg will be scanned; /images/flowers/red/pic1.jpg will not be scanned.

Don’t want to try installing it yourself?

No problem – drop me an email and I can install it for you for a minimal amount.

 

sitemonitor

This free to download version of SiteMonitor is based on a contribution written by Jack_mcs and modified by pyramids for cre loaded in 2006. This version updated April 2011.

What it does:
SiteMonitor emails you any changes to the files and folders you specify to monitor. It compares various file details with a reference file created at installation and if the current file details don’t match the reference, off goes the email to you. After creating the reference file, SM is best run as a cronjob daily.

How it works:
SM takes a snapshot (reference.txt) of files and folders specified by you and compares this to the current details of your files and folders.
SM watches for –

  • any new files to monitored folders
  • any deletions
  • any changes in file size
  • any changes in permission settings
  • any time stamp mismatches (so watching for file changes even if size kept the same)

SM can also be used to journal changes you make to your own website, as it writes all details to log.txt.

This version:
This version of SiteMonitor does not have the Admin interface of the original contribution by jack_mcs, which means you must hardcode the settings in the SM file first before running it. However the advantage here is that there is only 1 file to deal with – all of the functions etc have been combined into one script.

SM is also ideally run as a cronjob (an automated server process that you set and forget.)

The downloadable .zip (37KB) contains:

  1. sitemonitor files in their directory structure (the main programme)
  2. SM_instructions.txt (a short list of instructions, plus example reference file, log file, and email message)
  3. Version Checker (so you can keep up-to-date with new releases)

Fill out your name, email address to receive an email with the download link (37KB, zip file):
[lab_subscriber_download_form download_id=4]

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

<?php
/*
  $Id: 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)?

////NO NEED TO EDIT BELOW THIS LINE////////////

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

function scrollmarquee(){
if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8))
cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px"
else
cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
}

function initializemarquee(){
cross_marquee=document.getElementById("vmarquee")
cross_marquee.style.top=0
marqueeheight=document.getElementById("marqueecontainer").offsetHeight
actualheight=cross_marquee.offsetHeight
if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
cross_marquee.style.height=marqueeheight+"px"
cross_marquee.style.overflow="scroll"
return
}
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)
window.onload=initializemarquee

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

<script type="text/javascript" src="<?php echo DIR_WS_JAVASCRIPT;?>marquee.js"></script>
</head>

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

$info_box_contents[] = array('align' => 'center',
                             'text' => '<div id="marqueecontainer" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"><div id="vmarquee" style="position: absolute; width: 98%;">' . $bestsellers_list . '</div></div>');
      new $infobox_template($info_box_contents, true, true, $column_location);

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

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