Sort Shipping Modules by cost

Sorting the shipping modules is simple in osCommerce – just amend the sort order in the admin area. This is fine to do and works well.

I was recently approached to come up with an idea to sort the shipping modules based on the cost of shipping. This is much more difficult if the shipping modules are dynamic (eg, zones.php, table.php and so on).

With some lateral thinking I managed to come up with an idea and got some code that works;

This simple setting sorts the shipping modules by cost!

If the setting is “False”, then the modules look like this:

And if “True”, then this:


The main issue is that it is impossible to sort based on any type of sort_order via the admin IF the shipping module produces a dynamic price, that is a price that changes based on the value/weight of the order.

Shipping Module powered by CSV

Approached recently to quote for building a shipping module, powered by a CSV file.

The CSV file

Contains 4 pieces of information;

postcode, shipping_cost, amount at which shipping becomes free, courier name

The CSV file can consist of thousands of such entries.

Shipping Module (Shop)

This reads the CSV and outputs the necessary information;

Shipping Module (Admin)

Is pretty much the same as any other shipping module. Other than the store owner can set up a “default” courier, cost etc just in case the postcode cannot be found in the CSV file.

All in all, quite a nice little project!

I’m pretty sure that this will (at some point) make it into the addons area at osCommerce as this client specifically required the files in a format that would allow him to contribute it.

The Cherry on the Cake

How about a little feature in the shopping_cart.php page to show a shipping estimation? Well, that was done as well;

Here you can also see the message that it’s only another $50 or so to get free shipping…

Video in Action

Category View: Grid or List?

In the ongoing project that I am working on, the client decided that he would like the ability to choose how each category displays; whether it be a “grid” view, or a “list” view…

There are a few older forum posts about this, and some sites have some good examples of something very close in action. A typical example is Matts site (example category page) where the user can change the view from list to grid and vice-versa.

We needed something slightly different, as we need the Admin to decide the correct view and then not have the ability for the user to change it.

Has the ability to choose how the category is shown. If “list” is selected (which it is by default), then the usual osCommerce product_listing modules is shown. If “grid” is selected, then a new coded module is shown.

Shop “List” view

Shop “Grid” view

It’s a pretty good idea, as sometimes it is better for the end-user to have the available information presented in a different way. Whatever is better for the end-user is usually better in terms of the shops’ bottom-line !!

System for assigning products to specifications

Currently working on a modification that allows the shop owner to easily add new “specifications” and then assign products.

A typical use for this would be in a clothes shop. Sometimes clothes come in men, women, unisex. My new system would give the ability to have these specifications set out like the manufacturers are, and show products in that way.

It’s kind of hard to explain, so here’s a few images;

Adding the Specifications

Assigning Specifications to Products

The Specifications Menu

which shows the products in that the usual “product listing” style;

The Specifications Reminder box

When looking at a product that has a specification, the specification image shows for all the specifications attached to the product!

Pretty nifty modification, which seems to work well. I know there are a couple of similar things floating about, but none of them suited the clients needs, as I will (in the future) need to integrate some older custom code into this – therefore it is easier (and cheaper!) for me to make this from scratch than try to work with other peoples contributions.

More uses?

Perhaps this could go really well to show ratings for DVDs and Bluray – U, PG, 12a, 18 and such. Or maybe for a Pet shop that has products that can be used for many animals, this product is great for rat, gerbil, mouse…

Pretty much any shop that sells an item that is usable for more than 1 use, I think this mod would be good for.

Minimum Items to Checkout

Was contacted recently by someone who wanted the ability to define a minimum number of items in the cart to allow checkout. The answer to this is very simple; in checkout_shipping.php, use $cart->count_contents() and link that to a tep_redirect back to shopping_cart if the number is not big enough;

if ($cart->count_contents() < 5) tep_redirect(tep_href_link(FILENAME_SHOPPING_CART)); So, if there is less than 5 items in the cart, they cannot progress through the checkout. Then I got to thinking. What about if the shopowner wanted the buyer to have at least 5 different items in their cart before checking out? Again, something similar, but instead of using cart->count_contents(), use $cart->get_product_id_list()

I thought that something like this might come in handy one day, so I set out to make it. Within an hour I had the basics in place;


This shows the three options that I coded;

Minimum Items.
“What is the minimum number of items to allow checkout”. If the shopowner inserted the number 3, then the buyer would be forced to add at least 3 of EACH product to his cart.

Minimum Items (Overall)
“Minimum number of items per order overall to allow checkout”. If the shopowner inserted 5 here, then the buyer would need to have at least 5 products in his cart in order to checkout. These 5 could be ANY combination; 5 of the same product, 5 different, 3 of 1 and 2 of another and so on.

These also work in conjunction with each other.

So, let’s say that “minimum items” is set to 2, and “minimum items (overall)” is set to 6. Logic would say that the buyer is forced to buy at least 2 of any item, but 6 overall, thus:

What the buyer could do is purchase 6 of 1 item and this would be OK as it satisfies both the “minimum items” and “minimum items (overall)” rule;

Or the buyer could purchase 2 of 1 item and 4 of another (as this also satisfies the rules);

Let’s take an example that at first glance appears to satisfy the rules; (eg, 2 of 1 product, 3 of another product and 1 of another) – this will not complete checkout. The example breaks the “minimum items” rule, but satisfies the “minimum items (overall)” rule;

Minimum Items (Different, Overall)
“Minimum number of different items allowed in order” – this number signifies the amount of DIFFERENT products that the buyer is forced to purchase!

So, keeping the previous example (2 of 1 product, 3 of another product and 1 of another), and setting the “Minimum Items (Different, Overall)” to (say) 4…this will fail TWO rules. As we have only 3 products in the cart -> failure of “Minimum Items (Different, Overall)”, and as we are buying only 1 of a particular item -> this fails “Minimun Items”;

Let’s correct the order to satisfy all of the rules;

We now have;

  1. At least 2 quantity of each product -> satisfies “minimum items” rule
  2. 9 quantity being purchased -> satisfies “minimum items (overall)” rule
  3. 4 products being purchased -> satisfies “minimum different items (overall)” rule

Using a mixture of these three rules, enables the shopowner to have really good flexibility with what is being sold.

Typical “rule failure” example

This cart breaks all three rules and so there are 3 error messages. The shopowner can change the error messages to make them more flowery or understandable for the buyer.

Barclays Pingit Payment Module for osCommerce

Earlier today, Barclays bank launched a new “payments via mobile phone” service called Pingit. You can read about it here and here. And the official Barclays page here.

Seems like an ideal way to accept small payments for small businesses and personal use. Might force the likes of Paypal and all those other assorted payment processors to come up with some more realistically priced offerings.

A module for osCommerce

Anyway, I came up with a very basic Pingit Payment Module for osCommerce. It’s at and is released on the basis that it is v1.0 and so is highly likely to change over the coming weeks and months.


Is super simple. Just add it as you would any payment module. Then edit it to add your mobile number and the max amount you would want to accept per order.

In use

If the order value exceeds your “max amount” then the payment module does not show. If the payment module is available, and the buyer chooses to use it, then they are asked for their “pingit” mobile number on the checkout_confirmation page.


This number is written to the order_history and can be seen in the order details page in admin. This allows you to tie up the order to the pingit amount that you receive from that mobile number.

It’s all straightforward. It’s a very basic implementation, and you use at your own risk. If anyone who does use it needs changes, I can quote to make those changes if you cannot manage to make them on your own.

Update all currencies by CSV

osCommerce comes with a built in currencies updater which is operated manually and gets rates from “oanda” and “xe” – both of which are well known currency converter sites. In addition, it is possible to manually update the currency rates one by one.

For some sites, it is desirable to update prices 10 times or more each day, and to do this manually is a chore, especially if the shopowner has multiple currencies. For example a site selling gold. The price of gold fluctuates wildly day by day, even hour by hour!

I was approached by a client who wanted a CSV input box which would allow them to update all their currencies in one go. So, they would input something like:


Then press “update”, and all of the currencies are updated in one go. This saves a massive amount of time daily.

The end result:

And Video:

Must Agree to Terms and Conditions

There are a couple of Terms and Conditions addons floating about, but I decided that none of them were quite suitable for the needs of my latest client.

What the client wanted is three-fold;

1. Have a link in the checkout_confirmation page, which, when clicked pops up the Terms and Conditions for the buyer to read. This popup to also have a “cancel” button which kicks the user, and a “continue shopping” button which allows the user to remove the close the popup.

2. Have a tickbox in the checkout_confirmation, which, when clicked makes the “continue” button appear. In the popup, if the “continue shopping” button is pressed, this tickbox is automatically ticked.

3. Have the Terms and Conditions popup automatically as soon as the checkout_confirmation.php page is accessed.

So, now we know the needs, it is possible to make it happen. I used the jquery modal dialog box to show the info. This linked to the text to make it appear.

Link and Tickbox (no continue button):

When the Tickbox is ticked (continue button appears):

And if the Link is clicked up pops the information:

Remember also, that this information popup is also open by default each and every time the checkout_confirmation.php page is accessed – meaning the buyer must either choose to “continue” [in other words continue to checkout] or “cancel” [log off].

It’s kind of hard to explain, so here’s a video;

Pagination in New Products for (on index page)

In response to an exquiry I decided to have a go at coding up a system of pagination for the “New Product for month” module that is shown on the index page of osCommerce sites.

With a little change in the php code of the module I managed to get it to work;

And here is a Youtube showing it in action;

2.3.1 Design eBook Supplement – add some candy

In this blog post I’m going to show how to add a dialog “cart contents” popup to the breadcrumb area of the theme made in the 2.3.1 Design eBook.

First of all, I’ll show you a couple of images…

The “cart summary” link in the right hand side of the breadcrumb;

And the Dialog Box PopUp, which is what shows when the link is clicked;

Step 1: Open up /includes/template_top.php


Step 2: Open /includes/header.php

A. Reduce the grid_* by two on both the searchbox and the breadcrumb.
B. Remove the omega from the searchbox
C. Add the following block after the searchbox div:

D. Email me for the new “head cart” module (code doesn’t play nicely in this blog for some reason).

As easy as that. A couple of extra style bits in the user stylesheet and the job is completed.