SEO

SEO Friendly Breadcrumbs

This is a simple change you can make in includes/application_top. Instead of the product model number appearing in the Breadcrumbs trail, the product name will appear.

use for OSCommerce versions: 2.2rc2a and 2.3

Instructions:
Open includes/application_top.php.

find:
// add the products model to the breadcrumb trail
if (isset($HTTP_GET_VARS['products_id'])) {
$model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
if (tep_db_num_rows($model_query)) {
$model = tep_db_fetch_array($model_query);
$breadcrumb->add($model['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));
}
}

change to:
// add the products name to the breadcrumb trail
if (isset($HTTP_GET_VARS['products_id'])) {
$model_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
if (tep_db_num_rows($model_query)) {
$model = tep_db_fetch_array($model_query);
$breadcrumb->add($model['products_name'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));
}
}

That’s it.

This simply changes the query from the products table to the products_description table where the products name is stored in the products_name field. Since both tables are keyed to the same products id (products_id), the same product is pulled from the database regardless of whether the breadcrumbs query searches the products table or the products_description table.


Quantity Box

Add a quantity text box before the ‘add to cart’ button on the product page to allow a quantity to be posted to the shopping cart.

Demo:


Step 1:

in includes/application_top.php
find:
$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);



change to:

$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+$HTTP_POST_VARS['cart_quantity'], $HTTP_POST_VARS['id']);


( This changes the +1 to
$HTTP_POST_VARS['cart_quantity'] )

Step 2:

in product_info.php
find:

<?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?>


just in front of that add:

<input type="text" name="cart_quantity" value="1" maxlength="2" size="2">





(this is also posted on ‘Tips and Tricks’ section of the OSCommerce Forum)
Add a Quantity box

Product MiniDescriptions for OSCommerce 2.3

Product MiniDescriptions for OSCommerce 2.3




Adding minidescription to your product listing in OSCommerce 2.3 is easy:

  1. Create a new field in products_description. (use the following in phpMyAdmin)

    ALTER TABLE `products_description` ADD `products_minidescp` TEXT NOT NULL

    Then type the product mini-descriptions directly into the database.

  2. On about line 121 in index.php
    change:

    case 'PRODUCT_LIST_NAME':
    $select_column_list .= 'pd.products_name, ';
    break;

    to this:
    case 'PRODUCT_LIST_NAME':
    $select_column_list .= 'pd.products_name, pd.products_minidescp, ';
    break;

  3. In includes/modules/product_listing.php
    change this:
    case 'PRODUCT_LIST_NAME':
    if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
    $prod_list_contents .= ' <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></td>';
    } else {
    $prod_list_contents .= ' <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></td>';
    }

    to this:

    case 'PRODUCT_LIST_NAME':
    if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
    $prod_list_contents .= ' <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a><br/>'. $listing['products_minidescp'].'</td>';
    } else {
    $prod_list_contents .= ' <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a><br/>'. $listing['products_minidescp'].'</td>';
    }

That’s it!

In OSCommerce 2.2RC2a step three above is different:
3. In includes/modules/product_listing.php
change this:
$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';

To this:

$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a><br/>'. $listing['products_minidescp'];

Prevent Double Order Submissions with JQuery

Prevent double order submissions with JQuery. Use javascript to disable the ‘confirm order’ button on checkout_confirmation.php after submission, after it is clicked, and replace it with a message box complete with a spinner gif. Message box will match the Themeroller theme you are using.
None of the order processing programming is changed. The page will either proceed to checkout_success.php or refresh with error messages as normal. If the user has javascript disabled the button will function and display as usual.

Installation is simple. In OSCommerce 2.3 and OSC 2 CSS the required JQuery library, jquery-1.4.2.min.js is already in place.

All you need to do is the following:

  1. Add this to the stylesheet.css:
    .align_center{
    text-align: center;
    }

    .hide_msg{
    display: none;
    position: absolute;
    }

  2. On checkout_confirmation.php:

    about line 320, find:

    <div style="float: right;">
    <?php
    if (is_array($payment_modules->modules)) {
    echo $payment_modules->process_button();
    }
    echo tep_draw_button(IMAGE_BUTTON_CONFIRM_ORDER, 'check', null, 'primary');
    ?>
    </div>

    Then:

    1. Add the id ‘confirm’ to the div like so:
      <div style="float: right;" id="confirm">


    2. Finally, just above that add:

      <!--msg box-->
      <script type="text/javascript">
      $(document).ready(function(){
      $('#confirm').click(function(){
      $('#confirm').hide();
      $('#order_submitted').removeClass('hide_msg');
      })
      })
      </script>
      <div id="order_submitted" class="hide_msg">
      <div class="ui-widget infoBoxContainer" style="float: right;">
      <div class="ui-widget-header infoBoxHeading">Order Submitted</div>
      <div class="ui-widget-content infoBoxContents">
      <p class="align_center">Please Wait while your order is processed.</p> <p class="align_center"><?php echo tep_image('ext/jquery/bxGallery/spinner.gif'); ?></p>
      </div>
      </div>
      </div>
    3. In OSC to CSS the spinner gif is in the images file, and called ‘loading.gif. Thus, change the path from ‘ext/jquery/bxGallery/spinner.gif’ to ‘images/loading.gif’ (or to where you have another suitable animated gif located).

      That’s it. Whenever someone submits an order, they will be unable to re-click the ‘confirm order’ button and cause a double submission of the order.

    Note:
    Ideally the javascript snippet (everything between the script tags above) would be placed within the head tags of the page checkout_confirmation.php, but in OSCommerce 2.3 this would require additional programming. If you place it within the head tags as 2.3 is currently written, then the snippet would appear in the head of all catalog pages. In OSC to CSS, however, you can easily do this, as each catalog page has it own closing head tag.


OSC-to-CSS V2

4 Jquery Features installed on V2. Download from OSCommerce.

Product Tabs
Click to enlarge


Product Tabs
Json Add To Cart Mod
Click to enlarge


Json Add to Cart
Pretty Photo Lightbox
Click to enlarge


Pretty Photo
Superfish Horizontal Menu
Click to enlarge


SuperFish Navigation

Live Demo

Special Features New on Version 2.0:

960 Grid System

This new version, v2.0,
incorporates the
960 grid system.
The 960 grid system greatly facilitates alignment, proportion and
layout issues. It speeds up design, creates consistency and solves
cross browser problems.

JQuery/Json ‘Add to Cart’

Click ‘add to cart’ and without the page refreshing a JQuery lightbox-like popup appears to let the customer know a product has been
added to the cart. Complete with drop downs for options and links to ‘continue’ and ‘checkout’.

JQuery Product Information Tabs

The product information page comes installed with tabbed panels. Infoboxes have been installed to fill the
panels with product reviews, manufacturer info and more.

JQuery SuperFish NavBar

SuperFish JQueryNavigation Bar. Easily modified with it’s own stylesheet. See the Superfish site for neat plug-ins
and tips.

Reorganized Stylesheets

Improved and simplified organization esp. in regards to the product listings makes them far easier to work with.
V2.0 has Separate stylesheets for the jquery components, for text and for the 960 grid system.

InfoBoxes:

The infoboxes have been rewritten to operate inpendently. You can place any infobox anywhere and style it
separately according to where it is located.

Buttons

Buttons are CSS generated and have their own stylesheet. This feature can revert to standard buttons easily.

Jquery Pretty Photo

Highlight a full size product photo with a professional lightbox popup.

JQuery Lightbox for OSCommerce Product Listings

Add a JQuery Lightbox to the OSCommerce OSC to CSSv2 product listings.

Products listing:
Demo

New Products listing:
Demo

  1. Add a extra field the products table in the database.

    ALTER TABLE `products` ADD `products_image_large` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `products_image_list`

  2. Make two sets of all your product images.
    One set should be about 100px by 100px, and another set about 300px by 300px. You probably already have a set of small images in the field products.products_image. Then using phpMyAdmin or similar enter the references to the large images into the new field, p.products_image_large.


    valid email message
  3. Upoad all images to the catalog/images folder.
  4. Add these references to the head of catalog/index.php. In OSC to CSS this will be just above the references to template_top.php.

    <link rel="stylesheet" href="css/prettyPhoto.css" type="text/css" media="screen" />
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/jquery.prettyPhoto.js"></script>
    <!--pretty photo-->
    <script type="text/javascript" charset="utf-8">
    $(document).ready(function(){
    $("a[rel^='prettyPhoto']").prettyPhoto({
    animationSpeed: 'normal',
    padding: 30,
    opacity: 0.5,
    showTitle: true,
    allowresize: true,
    counter_separator_label: '/',
    theme: 'light_rounded',
    hideflash: false,
    wmode: 'opaque',
    autoplay: true,
    modal: false,
    changepicturecallback: function(){},
    callback: function(){}
    });
    });
    </script>

    note: if you are already using JQuery you will not need to add the reference to the main JQuery file.

  5. go to Pretty Photo and down load the pretty photo package. Extract the files and upload three files and one folder to your site in the following structure:
    • js/jquery.js
    • js/jquery.prettyPhoto.js
    • css/prettyPhoto.css
    • images/prettyPhoto

  6. Open catalog index.php
    change:

    case 'PRODUCT_LIST_IMAGE':
    $select_column_list .= 'p.products_image,';
    break;

    to:

    case 'PRODUCT_LIST_IMAGE':
    // add large image field to query
    $select_column_list .= 'p.products_image, p.products_image_large,';
    break;

    This adds the new field holding the references to your large images to the existing query in index.php

  7. Open includes/modules/product_listings.php
    change

    $lc_text = '&nbsp;<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>&nbsp;';

    to

    $lc_text = '<a rel="prettyPhoto" title="'.$listing['products_name'].'" href="' . tep_href_link(DIR_WS_IMAGES . $listing['products_image_large'], $listing['products_name']) . '" >' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br/><span class="small">(click to enlarge)</span></a>';

  8. To add the lightbox to the new products module, open includes/module/new_products.php
    change:

    <div class="pl-image"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image_list'], $new_products['products_name']) . '</a></div>

    to:

    <div class="pl-image"><a rel="prettyPhoto" title="'.$new_products['products_name'].'" href="' . tep_href_link(DIR_WS_IMAGES . $new_products['products_image_extra'], $new_products['products_name']) . '" >' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br/><span class="small">(click to enlarge)</span></a></div>


JQuery Horizontal Category Menu

The menu functions exactly as the menu in the categories box, except horizontal. The menu will function in pure CSS or with smooth JQuery functioning. Download from OSCommerce.

The dropdown subcategory links produce a shadow effect.

Demo

Adapted from:

Category Box as Nested Unordered List for EZ(er) CSS & Dynamic menus

and

Superfish Jquery Menu plugin

JQuery Forms Validation for OSCommerce

JQuery Forms Validation for OSCommerce allows users to recieve error messages ‘on the fly’ as they fill out forms on OSCommerce, without having to wait for page submit and refresh. In addition the error message appears on the field that is incorrectly filled out. Jquery provides unique messages for simple text forms, login, password and email forms. This replaces the older original OSCommerce javascript popup messages, but works alongside and in conjunction with the OSCommerce php messagestack-> function.

adapted from: Bassistance:Jquery Validation Plugin

See screenshots below:


Installation

1) Upload these files to the folder catalog/js on your website:
jquery.login.js

jquery.validate.js

jquery.js or jquery.min.4.2.js
(note:If you are already using Jquery on your site, you probably already have one of these two files installed. Only one is needed.)

-Links to the files jquery.validate.js and jquery.js can be found on the Bassistance site -


2) Place these references in the head of the catalog page that contains the form to validate. For example, login.php and account_password.php. If you are using OSC to CSS , this would look like:


<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script src="js/jquery.validate.js" type="text/javascript"></script>
<script src="js/jquery.login.js" type="text/javascript"></script>
<?php require(DIR_WS_INCLUDES . 'template-top.php'); ?>

(placing it just above the reference to template-top in login.php places these references just above the closing head tag, </head>, but only on login.php.)


3) Place this CSS selector in your stylesheet. Style as desired:

/*jquery validation errors*/
label.error {
/* remove the next line when you have trouble in IE6 with labels in list */
color: red;
font-style: italic;
font-family: 'lucida grande', helvetica, verdana, arial, sans-serif
}


4) Add these id and classes to the forms and text fields on the forms to validate, for example here in login.php and account_password.php.
On login.php

  1. find:
    <?php echo tep_draw_form('login', tep_href_link(FILENAME_LOGIN, 'action=process', 'SSL')); ?>
    Change to:
    <?php echo tep_draw_form('login', tep_href_link(FILENAME_LOGIN, 'action=process', 'SSL'),'post','id="signupForm"'); ?>
  2. find:
    <?php echo tep_draw_input_field('email_address'); ?>
    change to:

    <?php echo tep_draw_input_field('email_address','','class="required email" '); ?>
  3. find:
    <?php echo tep_draw_password_field('password'); ?>
    change to:
    <?php echo tep_draw_password_field('password','','id="password"'); ?>



On account_password.php>

  1. find:
    <?php echo tep_draw_form('account_password', tep_href_link(FILENAME_ACCOUNT, '', 'SSL')', 'onSubmit="return check_form(account_password);"') . tep_draw_hidden_field('action', 'process'); ?>
    Change to:
    <?php echo tep_draw_form('account_password', tep_href_link(FILENAME_ACCOUNT_PASSWORD, '', 'SSL'), 'post','id="passwordForm"', 'onSubmit="return check_form(account_password);"') . tep_draw_hidden_field('action', 'process'); ?>
  2. find:
    <?php echo tep_draw_password_field('password_current')
    change to:

    <?php echo tep_draw_password_field('password_current','','class="required"')
  3. find:
    <?php echo tep_draw_password_field('password_new')
    change to:

    <?php echo tep_draw_password_field('password_new','','id="password_new" ')
  4. find:
    <?php echo tep_draw_password_field('confirmation')
    change to:
    <?php echo tep_draw_password_field('confirmation','','id="confirmation" ')



The Jquery file jquery.validate.js also has ‘rules’ and classes for credit card fields and more. Using the pattern above, you can easily adapt JQuery forms validation to contact.php, create_account.php, account_edit.php, checkout_payment.php and other OSCommerce pages that use text forms, or even checkbox and drop-down menus. For a complete set of examples, demos and necessary files visit Bassistance:Jquery Validation Plugin

Elegant Muted Grey ‘Skin’ for OSC to CSSv2

This file set consisting of 3 stylesheets and 6 background images will give the OSC-to-CSS v2 a grey muted elegant look. Download from OSCommerce.

Installation:
Upload and overwrite to your existing files in your CSS and Images folders.


skin grey
Click to enlarge


screenshot
skin grey
Click to enlarge


top navigation

Live Demo

CSS Product Listings

Add stylesheet control to the layout and design of the category product listings on the index. No new files or database changes required.


Demo


Step 1

add the following code (new class definition) to includes/classes/boxes.php before the final ?>


///// BOF CSSTABLEBOX //////
class csstableBox {

// class constructor
function csstableBox($contents, $direct_output = false) {

for ($i=0, $n=sizeof($contents); $i<$n; $i++) {
if (isset($contents[$i]['form']) && tep_not_null($contents[$i]['form'])) $csstableBox_string .= $contents[$i]['form'] . "\n";
$csstableBox_string .= ' <div class="cssproduct_listing_item" >' . "\n";

if (isset($contents[$i][0]) && is_array($contents[$i][0])) {
for ($x=0, $n2=sizeof($contents[$i]); $x<$n2; $x++) {
if (isset($contents[$i][$x]['text']) && tep_not_null($contents[$i][$x]['text'])) {
$csstableBox_string .= ' <div class="cssproduct_listing_content">';
if (isset($contents[$i][$x]['form']) && tep_not_null($contents[$i][$x]['form'])) $csstableBox_string .= $contents[$i][$x]['form'];
$csstableBox_string .= $contents[$i][$x]['text'];
if (isset($contents[$i][$x]['form']) && tep_not_null($contents[$i][$x]['form'])) $csstableBox_string .= '</form>';
$csstableBox_string .= '</div>' . "\n";
}
}
} else {
$csstableBox_string .= ' <div class="cssproduct_listing_content">' . $contents[$i]['text'] . '</div>' . "\n";
}

$csstableBox_string .= ' </div>' . "\n";
if (isset($contents[$i]['form']) && tep_not_null($contents[$i]['form'])) $csstableBox_string .= '</form>' . "\n";
}

$csstableBox_string .= '<div class="cssclear"></div>' . "\n";

if ($direct_output == true) echo $csstableBox_string;
return $csstableBox_string;
}
}

class cssproductListingBox extends csstableBox {
function cssproductListingBox($contents) {
$this->csstableBox($contents, true);
}
}

////// EOF CSSTABLEBOX //////


Step 2

add the following to includes/stylesheet.css


.cssproduct_listing_content{
border: 1px dotted #bbc3d3;
border-width: 0px 0px 0px 0px;
width: 140px;
padding: 2px 0px 2px 0px;
margin: 0px 0px 0px 0px;
}

.cssproduct_listing_item{
float: left;
width: 155px;
height: 165px;
border: 1px solid #bbc3d3;
border-width: 1px 1px 1px 1px;
font-family: Verdana, Arial, sans-serif;
font-size: 10px;
text-align: center;
padding: 5px 0px 5px 5px;
margin: 5px 5px 5px 5px;
}

.cssclear{clear: both;}


Step 3

In includes/modules/product_listing.php:
about line 68 comment out the following.
ie change:


'params' => 'class="productListing-heading"',
'text' => ' ' . $lc_text . ' ');


to

// $list_box_contents[0][] = array('align' => $lc_align,
// 'params' => 'class="productListing-heading"',
// 'text' => ' ' . $lc_text . ' ');


and change:



new productListingBox($list_box_contents);


to:


// new productListingBox($list_box_contents);
new cssproductListingBox($list_box_contents);


also posted on the OSCommerce forum under ‘Tips and Tricks’: CSS Product Listings