Modules in osCommerce – making them interactive

Sometimes you might want to show a Payment or Shipping Module based on other factors. A few examples;

  • Only show Paypal payment method if USPS shipping is chosen.
  • Only show Flat Rate Shipping if number of items in cart is less than three
  • Only show USPS if the total purchase value exceeds $500

I’m sure you get the idea. So, all you need to do is put in an “if” statement, and if the “if” statement is true (or false) – depends upon what you need – turn the shipping or payment module on or off appropriately.

Let’s look at Only show Flat Rate Shipping if purchase value is $200 or more

We know that Flat Rate Shipping is controlled by the shipping module:
/includes/modules/shipping/flat.php so open this ready for a code addition.

Looking at this file, we can plainly see that we can stop the module from working by using this code:

[php]$this->enabled = false;[/php]

And we can get the value of the purchase via this code:


So, putting those together, we need to do this:

[php]if($cart->total < 200) $this->enabled = false;[/php]

IF purchase value is $200 or less, don’t give a shipping quote! Easy as 123. Add that line of code right underneath:

[php]$this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == ‘True’) ? true : false);[/php]

We need to make one more change. We need to access the cart on a global level, so change this line of code (approx line 18):

[php]global $order;[/php]

to this:

[php]global $order, $cart;[/php]

Now go to your Admin section and activate the Flat Rate module. It will only give a quote if the customer has $200 or more in their cart.

Affiliate Scheme launched on osCommerce Books

Hi all, I’ve been running an affiliate scheme on for some years, on which I paid 33% commission. Recently I swapped the site over to a new look and a new payment/delivery processor. At the same time as I updated the website, I decided to reward affiliates by paying 50% commissions for a 3 month period.

That 3 month period is up now, but I decided to stay at that 50% commissions for the foreseeable future. Why not? Affiliates deserve to be paid a decent amount!

If you are interested in becoming an Affiliate of and earning 50% commission on sales that you refer, please contact me – my email address is up there ^

Orange and Grey button set

Spent some time cleaning out some old files from my computer and came across loads of old osCommerce bits and pieces of codes, projects, graphics and what-not.

Here’s a button set that I vaguely recall making:

Any good to anyone?

Download the full zip file of these Grey/Orange buttons here.

Unfortunately, I couldn’t find a PSD for the set, so you’ll have to make do with what there is in the .zip


More Questions about Discount Vouchers

Patrick asks;

We are looking for a gift voucher module with the following abilities:

1. Able to create a coupon code that can be used for everyone (also customers that have not yet signed up).
2. The coupon has a worth example 5 dollars
3. This can only be used one time only per customer

Is there a (paid) module that has these functions? Please point me in the right direction cause im kind of lost.

All 3 of your needs can be fulfilled right out of the box by my own GCDV contribution. With my contribution you are able to create a permanent coupon – just show the coupon code to new customer when they make an account. You can set a percent discount or a vlue discount. You can set the coupon use to be “once per custome”r or “multiple times per customer”.

And the contribution is FREE! The next version is more complicated and includes “tax calculations” and “coupon end date” as well as loads of other extras – this version is (at the moment) installable by me at a beer cost – it is not publically available. Should you (or anyone reading this) wish to have this new version installed, please email me on oscshops AT gmail DOT com


Web Hosting Upgrade Problems with osCommerce

Ron asks;

I am looking at web hosting co. It seems a lot of them do not have the current versions of: phpmyadmin, oscommerce, mysql. Can this be a problem?? If so what kind of problem??

Most hosting companies should by now have upgraded to PHP5 and MySQL5. If so, you need to use the latest version of osCommerce called “Rc2a”. Older version have problems dealing with the latest version of PHP and SQL.

You should always manually install osCommerce – NEVER use a host provided version as they are usually out of date.

I got your ebook “Designing OsCommerce“, it was fantastic for a newbie. Now if I use any/all of what you have in the book to change my site, and contributions from main oscommerce site. What problems can/does this cause when a host upgrades its versions of the software???

If you use the latest version of osCommerce, you’ve future-proofed yourself as much as possible. Of course, some contributions don’t work on the latest version of osCommerce – but those contributions are usually pretty poorly coded anyway, and should be avoided.

Long story short: use the latest version of osCommerce, keep it patched and updated (when patches and updates come out) and you have done as much as you can to future proof yourself…

Protx Live Service Upgrade on 22nd June 2008

ProtX are making some chganges to their IP address range, so if you use ProtX please read this.

To check if your site is using the correct URL, simply download and open /includes/modules/payment/protx_*.php (there might be one or there might be two). Make sure that the URL being used in each begins with

Easy as 123. If you need this checking, I can do so for you – email me on oscshops AT gmail DOT com

osCommerce – What’s New Here

Steve asks;

I have been using osC for a few years now and have been very happy with it except for a few minor things. The one thing that I could change to greatly improve osC’s usefulness (at least to me) is this:

Is there a way to add products to the site that do not show up on the “What’s New Here?” main page?

I sell CDs and DVDs and for most things having them automatically show up on the main page is fine. But I would like to list alot of used items, one-of-a-kinds, etc… that I would not want showing up as the newest things added to the site to be the first things the customers see when they visit…but they could click on a category such as “Used CDs” or “Bargain Discs” and there they would be….

Perhaps there is some way of doing this but I suspect it is something that requires knowledge of code. I do not actually have the osC software on my computer but I could get my web-designer to alter that code if need be. If it is something I could do as just on the administrator screens, then so much the better….

Steve – there is no option that allows you to not show the latest added products in the What’s New section on the front page. Probably the easiest way to get around this is to use that section as “Featured Products” instead of “What’s New” products. Simple to do, see here.

It’s a simple install, but if you cannot manage it, let me know by email and I can install it for you.

Once installed you’d select 9 products to show permanently on your “What’s New” section and any other products that you add would not be shown (until you deactivated 1 or more of your “featured” products).

Easy as 123.

Questions about Discount Vouchers

Aravot asks;

Looking for a discount / coupon contribution found your site, was wondering if your contribution creates and sends coupon to customer upon registration and when customer uses the coupon, it deletes it from db. If your contribution doesn’t do the above do you know any that does.

Aravot, my version of this does not send a coupon to a customer upon registration. It also does not delete from the DB after use.

However, coupons can be set up to be used only once per customer…so all you need to do is set up a permanent coupon of whatever % discount (on a use once basis), then send this coupon code to each new customer in their “welcome” email – or print the code (maybe print it funky using an image of a voucher) on the “create_account_success” page.

So, in a roundabout way, what you want can be done easily enough.

I do not recommend any of the other coupon contributions as they are all over-cooked and/or outdated codebase.

A few kind words…brightens the day

It’s always great to receive kind words from people that I have done work for or who are pleased with my efforts in helping the osCommerce Community. No fake testimonials on this website!

“fast service, the day we asked to install the contribution gary got it working on our site … easy communication and great service”


“Gary’s discount/gift voucher mod works beautifully. From initial installation request to completion was painless and took less than 24 hours. I’ve been bitten by unscrupulous contractors and approach developers with skepticism. Gary is one of the few that exudes confidence and trust. I will definitely look to him for future upgrades.”


“your’s is the only setup/install I have used that got all three needed components (Apache, PHP & MySql) to work for me. I could get Apache to work, but not MySql. Then I could get PHP installed correctly, but Apache wouldn’t “see” it. Then I’d get MySql to start, but. All in all, a very frustration exercise! Your install program worked as promised. Hooray!”

Thank You to you all!

Next update to discount vouchers

STOP PRESS: This contribution is now updated to Version 5 and has all sorts of cool extras. Please see the latest post about this.

At the moment I am working on a “date” function for the Discount Vouchers contribution. Basically when a coupon is set up, the store owner will be able to choose a start and end date for the coupon usage – so that if a Store has a promotion during (say) June, the coupon can be set up to only be available for use during June.

The Admin side is completely done. The shop side, I just need to do some basic trapping to determine if todays date is within the start/end date set up on the voucher.


Shows a coupon being set up – note the funky date calendar picker for the Start Date and End Date. Then shows what happens if todays date is outside the “start and end” dates. Then I set up another coupon called “test2” to show it working as it should do (if todays date is within the “start and end” dates).