How to install coupons module for osCommerce (notes on installation and configuration)

The purpose of this post is not to replace the original coupons module installation manual, but to provide answers that you might have while installing it. It is based on my own experience and might be different from yours. This post is a part of set related to installing and configuring your own store. Please read the master post here.

So you decided to install something that will allow coupons in your store. Here is how you can do that. Grab a couple of coffee cups as this one will be tricky. So, the coupons module I really like is “Discount Coupon Codes “.

  1. The installation of this plugin is a bit complicated. Don’t try overwriting the original osCommerce files!! Instead open manual.html file from the module distribution and follow steps listed in “Edit Existing files”, then copy new files to the the osCommerce distribution.
  2. While editing the existing files you should be careful as line numbers do not match in many cases.
  3. Mods to admin/includes/boxes/catalog.php and admin/includes/boxes/reports.php are missing periods at the end of the second line. Add them, otherwise your store will become inaccessible.
  4. catalog/includes/classes/order.php file changed significantly since the module was released, so you will have to be extra careful while rewriting that part. I rewrote it like this:
    //kgt - discount coupons
    if( is_object( $this->coupon ) ) {
    $applied_discount = 0;
    $discount = $this->coupon->calculate_discount( $this->products[$index], $valid_products_count );
    if( $discount['applied_discount'] > 0 ) $valid_products_count++;
    $shown_price = $this->coupon->calculate_shown_price( $discount, $this->products[$index] );
    $this->info['subtotal'] += $shown_price['shown_price'];
    $shown_price = $shown_price['actual_shown_price'];
    } else {
    $shown_price = $currencies->calculate_price($this->products[$index]['final_price'], $this->products[$index]['tax'], $this->products[$index]['qty']);
    $this->info['subtotal'] += $shown_price;
    $shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];
    $this->info['subtotal'] += $shown_price;
    //end kgt - discount coupons
  5. Beware of some drawbacks of this module:
    1. It doesn’t support stackable coupons
    2. Be careful and do not make coupon for amount more then the actual product price! The module incorrectly handles this situation
    3. The original module doesn’t support coupons for more then 999.99. To fix that alter the coupons table as following (issue this command in your db management program:
      alter table discount_coupons change coupons_discount_amount coupons_discount_amount decimal(17,12) not null default 0;

3 thoughts on “How to install coupons module for osCommerce (notes on installation and configuration)

  1. Hi Andrey,
    Do you know if the Discount Coupon Codes can be applied to shipping versus taking an amount off the product price. For example if I want to get free shipping for a coupon code how would I go about this?

    1. Hi Dave,

      Sorry, I don’t know that. In fact I set up my store a long time ago and since then I didn’t work with osCommerce anymore. When I’ll need to set up my next storefront (in a few months) I might become able to answer your question :)


Leave a Reply