Jump to content
kgt

[Contribution] Discount Coupon Codes

Recommended Posts

Hello. I recently posted this in general help as I did not see this topic.

 

Hoping to get a little more help help.

 

I recently installed this contribution using the automatic installer

 

The problem I am having is that the first time the user clicks continue after entering the coupon code, nothing shows up. it merely goes to the checkout confirmation page. Only if the user goes back a page and click continue again with the code entered will the coupon code register.

 

any subsequent time the user goes through the checkout process while still in the same login session the code works. It is only the first time after login that it does not which is also very important.

 

Any ideas off the top that you could think of to fix this?

Share this post


Link to post
Share on other sites

Hi,

I have set Discount Coupons to exclude products with a special offer on, when trying to buy a product on special with a coupon I get a HTTP 406 error.

 

The error comes up in the URL: "https://www.gale-force.org.uk/checkout_payment.php?error_message=The+minimum+order+total+for+this+coupon+is+%A350.00.+Some+or+all+of+the+products+in+your+cart+are+excluded."

 

For reference the error is:

"Not Acceptable

 

An appropriate representation of the requested resource /checkout_payment.php could not be found on this server.

 

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."

 

Do you know why?

 

Thank you,

Dave

Share this post


Link to post
Share on other sites

CHECK TO SEE IF YOU HAVE ANYTHING IN THE EXCLUDED PRODUCTS BOX

 

Hi,

I have set Discount Coupons to exclude products with a special offer on, when trying to buy a product on special with a coupon I get a HTTP 406 error.

 

The error comes up in the URL: "https://www.gale-force.org.uk/checkout_payment.php?error_message=The+minimum+order+total+for+this+coupon+is+%A350.00.+Some+or+all+of+the+products+in+your+cart+are+excluded."

 

For reference the error is:

"Not Acceptable

 

An appropriate representation of the requested resource /checkout_payment.php could not be found on this server.

 

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."

 

Do you know why?

 

Thank you,

Dave

Share this post


Link to post
Share on other sites
CHECK TO SEE IF YOU HAVE ANYTHING IN THE EXCLUDED PRODUCTS BOX

 

I do have it in the excluded products box. Therefore it should come up with an error saying to customers 'Some or all of the products in your cart are excluded' but instead it is coming up with the 406 error.

 

EDIT: To be precise it is in an excluded category

Edited by trogan

Share this post


Link to post
Share on other sites

Having a problem with this contribution. When the customer uses the coupon code, the order doesn't total correctly. The coupon code subtracts from the order total and then the subtotal is correct, adds tax to that and then the shipping doesn't compute properly. The shipping amount is correct from the shipping module. The amount it subtracts is the difference of the sum of the tax and the shipping. Anyone else with this problem?

Thanks,

Rob

 

Example:

Order 3 shirts @ $21.95 = $65.85

Discount Coupon $12.00

Sub total $53.85

Sales Tax $ 4.44

USPS shipping $ 5.50

Total $ 51.80 --- this total is wrong, it should be $63.79

Share this post


Link to post
Share on other sites

I have this module installed and wrks just fine. Also have the golden oldie Quantity Discounts http://www.oscommerce.com/community/contributions,1159

 

QTY discount has an option to disable it when a voucher is used. Doesn't seem to work with this contrib however. Does anyone have an idea how I can disable on of the two? I would prefer to hav the qty discount disabled when a coupon is used. See below for the code for ot_qty_discount.php.

 

Would really appreciate it when someone could help!

 

 

<?php
/*
 $Id: ot_qty_discount.php,v 1.4 2004-08-22 dreamscape Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2004 Josh Dechant
 Protions Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class ot_qty_discount {
var $title, $output;

function ot_qty_discount() {
  $this->code = 'ot_qty_discount';
  $this->title = MODULE_QTY_DISCOUNT_TITLE;
  $this->description = MODULE_QTY_DISCOUNT_DESCRIPTION;
  $this->enabled = MODULE_QTY_DISCOUNT_STATUS;
  $this->sort_order = MODULE_QTY_DISCOUNT_SORT_ORDER;
  $this->include_shipping = MODULE_QTY_DISCOUNT_INC_SHIPPING;
  $this->include_tax = MODULE_QTY_DISCOUNT_INC_TAX;
  $this->calculate_tax = MODULE_QTY_DISCOUNT_CALC_TAX;
  $this->output = array();
}

function process() {
  global $order, $currencies, $ot_subtotal;

  $od_amount = $this->calculate_discount($this->get_order_total());
  if ($this->calculate_tax == 'true') $tod_amount = $this->calculate_tax_effect($od_amount);

  if ($od_amount > 0) {
	if (MODULE_QTY_DISCOUNT_RATE_TYPE == 'percentage') $title_ext = sprintf(MODULE_QTY_DISCOUNT_PERCENTAGE_TEXT_EXTENSION ,$this->calculate_rate($_SESSION['cart']->count_contents()));
	$this->deduction = $od_amount+$tod_amount;
	$this->output[] = array('title' => sprintf(MODULE_QTY_DISCOUNT_FORMATED_TITLE, $title_ext),
							'text' => sprintf(MODULE_QTY_DISCOUNT_FORMATED_TEXT, $currencies->format($od_amount)),
							'value' => $od_amount);
	$order->info['total'] -= $this->deduction;
	$order->info['tax'] -= $tod_amount;
	if ($this->sort_order < $ot_subtotal->sort_order) $order->info['subtotal'] -= $this->deduction;
  }
}

function calculate_discount($amount) {
  global $qty_discount, $order_total_array;

  $od_amount = 0;
  if ((MODULE_QTY_DISCOUNT_DISABLE_WITH_COUPON == 'true') && (isset($_SESSION['cc_id']))) return $od_amount;

  $qty_discount = $this->calculate_rate($_SESSION['cart']->count_contents());
  if ($qty_discount > 0) {
	if (MODULE_QTY_DISCOUNT_RATE_TYPE == 'percentage') {
	  $od_amount = round((($amount*10)/10)*($qty_discount/100), 2);
	} else {
	  $od_amount = round((($qty_discount*10)/10), 2);
	}
  }

  return $od_amount;
}

function calculate_rate($order_qty) {
  $discount_rate = split("[:,]" , MODULE_QTY_DISCOUNT_RATES);
  $size = sizeof($discount_rate);
  for ($i=0, $n=$size; $i<$n; $i+=2) {
	if ($order_qty >= $discount_rate[$i]) {
	  $qty_discount = $discount_rate[$i+1];
	}
  }

  return $qty_discount;
}

function calculate_tax_effect($od_amount) {
  global $order;

  if (MODULE_QTY_DISCOUNT_RATE_TYPE == 'percentage') {
	$tod_amount = 0;
	reset($order->info['tax_groups']);
	while (list($key, $value) = each($order->info['tax_groups'])) {
	  $god_amount = 0;
	  $tax_rate = tep_get_tax_rate($key);
	  $net = ($tax_rate * $order->info['tax_groups'][$key]);
	  if ($net > 0) {
		$god_amount = $this->calculate_discount($order->info['tax_groups'][$key]);
		$tod_amount += $god_amount;
		$order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount;
	  }
	}
  } else {
	$tod_amount = 0;
	reset($order->info['tax_groups']);
	while (list($key, $value) = each($order->info['tax_groups'])) {
	  $god_amount = 0;
	  $tax_rate = tep_get_tax_rate($key);
	  $net = ($tax_rate * $order->info['tax_groups'][$key]);
	  if ($net>0) {
		$god_amount = ($tax_rate/100)*$od_amount;
		$tod_amount += $god_amount;
		$order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount;
	  }
	}
  }

  return $tod_amount;
}

function get_order_total() {
  global $order;

  $order_total = $order->info['total'];
  if ($this->include_tax == 'false') $order_total = ($order_total - $order->info['tax']);
  if ($this->include_shipping == 'false') $order_total = ($order_total - $order->info['shipping_cost']);
  return $order_total;
}

function check() {
  if (!isset($this->check)) {
	$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_QTY_DISCOUNT_STATUS'");
	$this->check = mysql_num_rows($check_query);
  }

  return $this->check;
}

function keys() {
  return array('MODULE_QTY_DISCOUNT_STATUS', 'MODULE_QTY_DISCOUNT_SORT_ORDER', 'MODULE_QTY_DISCOUNT_DISABLE_WITH_COUPON', 'MODULE_QTY_DISCOUNT_RATE_TYPE', 'MODULE_QTY_DISCOUNT_RATES', 'MODULE_QTY_DISCOUNT_INC_SHIPPING', 'MODULE_QTY_DISCOUNT_INC_TAX', 'MODULE_QTY_DISCOUNT_CALC_TAX');
}

function install() {
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Display Quantity Discount', 'MODULE_QTY_DISCOUNT_STATUS', 'true', 'Do you want to enable the quantity discount module?', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_QTY_DISCOUNT_SORT_ORDER', '2', 'Sort order of display.', '6', '2', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Disable If Coupon Used', 'MODULE_QTY_DISCOUNT_DISABLE_WITH_COUPON', 'true', 'Do you want to disable the quantity discount module if a discount coupon is being used by the user?', '6', '3','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Discount Rate Type', 'MODULE_QTY_DISCOUNT_RATE_TYPE', 'percentage', 'Choose the type of discount rate - percentage or flat rate', '6', '4','tep_cfg_select_option(array(\'percentage\', \'flat rate\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Discount Rates', 'MODULE_QTY_DISCOUNT_RATES', '10:5,20:10', 'The discount is based on the total number of items.  Example: 10:5,20:10.. 10 or more items get a 5% or $5 discount; 20 or more items receive a 10% or $10 disount; depending on the rate type.', '6', '5', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Include Shipping', 'MODULE_QTY_DISCOUNT_INC_SHIPPING', 'false', 'Include Shipping in calculation', '6', '6', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Include Tax', 'MODULE_QTY_DISCOUNT_INC_TAX', 'false', 'Include Tax in calculation.', '6', '7','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Calculate Tax', 'MODULE_QTY_DISCOUNT_CALC_TAX', 'true', 'Bereken Tax on discounted amount.', '6', '8','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
}

function remove() {
  tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
 }
?>

Share this post


Link to post
Share on other sites

Great contribution. Small problem, however...

 

No matter what setings I choose for the discount (in the admin panel), I am only getting the discount applied once. I have reviewed the notes (I did a manual install), and confirmed that I have not missed anyhting. Any ideas where to look on this?

 

I am using version 3.34 with osCommerce v2.2 RC2a

Share this post


Link to post
Share on other sites

Hi, everyone. I want to start off by saying that so far, I love the Discount Coupon contribution. I had absolutely no problems with the install, and am now in testing mode.

 

I slogged through pages of this thread, but couldn't find a solution to the problem I've uncovered during testing.

 

Here's the issue:

 

- I create a new coupon for 20% off (entering .20 in the admin panel).

 

- The coupon code field appears in the checkout process.

 

- On the order confirmation page, there are two issues:

 

(1) The discounted amount does not show up.

(2) The total amount is doubled instead of being 20% off (e.g., it shows $20 when the product was only $10 to begin with).

 

I installed the most recent version (3.34). I have 1 other contribution installed at this time (Additional Images), I made modifications to existing files instead of replacing them with the files include in the contrib.

 

Has anyone else experienced this? And does anyone have any recommendations for how I might troubleshoot it?

 

Thank you in advance for your help.

Share this post


Link to post
Share on other sites

Apparently the same problems exists if I don't enter a coupon code. I'm thinking it's a problem with checkout_confirmation.php? Please help!

 

Hi, everyone. I want to start off by saying that so far, I love the Discount Coupon contribution. I had absolutely no problems with the install, and am now in testing mode.

 

I slogged through pages of this thread, but couldn't find a solution to the problem I've uncovered during testing.

 

Here's the issue:

 

- I create a new coupon for 20% off (entering .20 in the admin panel).

 

- The coupon code field appears in the checkout process.

 

- On the order confirmation page, there are two issues:

 

(1) The discounted amount does not show up.

(2) The total amount is doubled instead of being 20% off (e.g., it shows $20 when the product was only $10 to begin with).

 

I installed the most recent version (3.34). I have 1 other contribution installed at this time (Additional Images), I made modifications to existing files instead of replacing them with the files include in the contrib.

 

Has anyone else experienced this? And does anyone have any recommendations for how I might troubleshoot it?

 

Thank you in advance for your help.

Share this post


Link to post
Share on other sites
Apparently the same problems exists if I don't enter a coupon code. I'm thinking it's a problem with checkout_confirmation.php? Please help!

 

Is anyone monitoring this forum? I'd prefer to fix the problem, rather than uninstalling the contrib...

 

Thanks again,

 

Jerri

Edited by fireserpent

Share this post


Link to post
Share on other sites
Is anyone monitoring this forum? I'd prefer to fix the problem, rather than uninstalling the contrib...

 

Thanks again,

 

Jerri

 

Resolved. Thanks for the help, everyone. ;)

 

Great contrib, though. Seems to work well for MS2.

Share this post


Link to post
Share on other sites

Installed and testing great - well done - BUT I NEED HELP!!!![/b] please.

 

Members will recieve a 100% discount for a period of time when downloading data only - Also using add-on Quantity Discount.

 

The problem I'm having is that I cant get past the payment details page - thats fine for non-members.

 

Is there a code that I can write in somewhere, that would go something like - if total equals $0.00 or -$x.00, then mark as payment received or something like that - this would allow the customer to get their download details for the items they want.

 

I'm just passed a newbie, so please be gentle with me :blush: I follow instructions very well.

 

thanks heaps!

Share this post


Link to post
Share on other sites

The module seems to be installed correctly for me, but I don't see the coupon code box anywhere. Any help?

Share this post


Link to post
Share on other sites
The module seems to be installed correctly for me, but I don't see the coupon code box anywhere. Any help?

 

I'm having the same problem with my installation. The install was fairly easy and the admin system works perfectly. However, there is not coupon box on the checkout_payment.php page. I'm not getting an error - the option to enter a coupon just doesn't show up.

 

The only information I've read is that there is some issue with setting a unique value to the module sort order. And I've read a recommendation to remove and then re-install all Order Total Modules. Neither of these recommendations works. But I have noticed an odd issue with my sort order settings. I can edit each module and set the sort order for each and this value shows up on the right where it displays the details under the remove or edit buttons. But the list of modules still shows the original modules listed with their original sort order. The Discount Coupon module sort order is blank in the listing. I assume there is something wrong with the Module install and sort order update but I have no clue what it could be.

 

Does anyone have any idea what the solution is for this?

 

Thanks

Pete

Share this post


Link to post
Share on other sites

I have this error when i click in Discount Coupons any one can help me ?

 

 

 

Warning: require(includes/classes/navigation_history.php) [function.require]: failed to open stream: No such file or directory in /home7/cdkeyhou/public_html/wow30daystimecard/includes/application_top.php on line 128

 

Fatal error: require() [function.require]: Failed opening required 'includes/classes/navigation_history.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home7/cdkeyhou/public_html/wow30daystimecard/includes/application_top.php on line 128

Share this post


Link to post
Share on other sites

I have uninstall the 3.4 and install the 3.2 auto-installer and now i have this error

 

Fatal error: Call to a member function add_current_page() on a non-object in /home7/cdkeyhou/public_html/wow30daystimecard/includes/application_top.php on line 319

 

helppp please

Share this post


Link to post
Share on other sites

Look at the links in my posts here: Click Me


If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Share this post


Link to post
Share on other sites

Ok so i did everything and no errors anywhere, seems like everything works good. I created a coupon in the admin then go to the user end and go through the checkout and type in my coupon code. It takes it with no errors but on the checkout_confirmation page where it shows the totals it doesnt show the discount and the total is still the same. I tried entering a bad coupon and get the error message so i know that when i use a right coupon it all works cuz it takes me to the next step...just doesnt show the total and discount.

 

Can anyone help?

Share this post


Link to post
Share on other sites
Ok so i did everything and no errors anywhere, seems like everything works good. I created a coupon in the admin then go to the user end and go through the checkout and type in my coupon code. It takes it with no errors but on the checkout_confirmation page where it shows the totals it doesnt show the discount and the total is still the same. I tried entering a bad coupon and get the error message so i know that when i use a right coupon it all works cuz it takes me to the next step...just doesnt show the total and discount.

 

Can anyone help?

 

Ok so if i have PayPal payment standard = true then coupons work fine, but if i use Paypal Payment Pro coupons do not work. On the final page through the checkout process where it supposed to show the amount deducted from the subtotal - it doesnt.

 

Does anyone have a fix for this or can help?

Share this post


Link to post
Share on other sites

I just uploaded a working and tested solution for orders.php considering the calculate_price as I noticed a lot was written on this subject and since orders.php changed the solution in contribution doesn't work for newer oscommerce installations such as 2.2rc2... or maybe even sooner, so check this out ....

 

Works great !


catalog/includes/classes/order.php file changed significantly since the module was released ..


//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

 

 

I have also noticed one bug, but overcome it with a trick that I just don't like ...

 

If I enter a discount as a number it's considered as VAT included and the order totals looks OK.

 

But, if I enter a 15% like 0.15 ... it will deduct only 12.5% ? Or is it deducting from NET amount only even that I have set VAT included in config .... I don't know, but its confusing ...

 

I can overcome this by entering +20% (our VAT here) for example I set 0.18 in settings and 15% is deducted in my order total ...

 

Did anyone else experience this ? Or did I miss something while installing ... ? All other seems to work just great thoe ... And even on top of SPPC :)

 

Any comments will be great on this matter !

 

Thx,

suhy

Share this post


Link to post
Share on other sites

I have a problem: 'Your calculated shipping charges have changed.'

 

Background:

My order is $53.

The coupon is $10 for any order.

The table rate is set to

- $5 shipping below $50, and

- $0 (free) shipping above $50.

 

What I do and what happens:

checkout_payment.php: I enter the coupon code.

It sends me back to:

checkout_shipping.php: 'Your calculated shipping charges have changed.'

Yet, the table rate still shows $0 shipping, so I am back at the beginning.

 

Obviously, the coupon does not get remembered back on the shipping page, therefore the total is still the old and the shipping module does not recalc the shipping fee.

The total still is $53 and the shipping shows $0.

I should have Amount $53 - Discount $10 = Subtotal $43+ shipping $5 = Total $47.

 

Should I configure something differently or is this a (known) bug?

I have version 3.33 installed.

Share this post


Link to post
Share on other sites

Oh and BTW I'm having/want Order Totals Modules in this order:

- Subtotal (without Discount)

- Shipping

- Discount Coupons

 

Maybe the culprit's in there somewhere too, or a combination thereof.

Share this post


Link to post
Share on other sites

Sorry if this has been asked but couldn't see it when skim reading but I have an issue were the coupon work for the customer money is taken off etc, but I do have a problem were if I have set a limit to how many time the coupon can be used it doesn't subtract the use off the total nor show how many times the coupon has been used.

 

Could someone be so kind to point me in the right direction thanks.

Share this post


Link to post
Share on other sites

Hello

 

In admin catalog.php I dont have like this :

 

'<a href="' . tep_href_link(FILENAME_PRODUCTS_EXPECTED, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_PRODUCTS_EXPECTED . '</a>' );

 

I have :

 

tep_admin_files_boxes(FILENAME_PRODUCTS_EXPECTED, BOX_CATALOG_PRODUCTS_EXPECTED).

 

What I must change?

 

thx,

 

drumer979

Share this post


Link to post
Share on other sites

I have been searching but cannot find the answer to my question so maybe someone on here can help. What I am trying to do is make a coupon that applies a discount percentage to an order, then subtracts a flat amount from the order.

 

Basically the example is:

Order total: $240

Discount 20%: $192

Discount $75: $117

 

The values really don't matter but that is the coupon I'm trying to create. I would really like it to be a single coupon that does both things but If I have to I could give the customer two coupons to enter. I know how to make the two coupons but I cannot figure out how to let the customer apply 2 coupons to their order. Currently the module only allows the customer to add a single coupon to the order.

 

In summary, I need to know how to make 1 coupon that offers 2 discounts, or how to let a customer enter multiple coupons to an order.

 

Thank you,

Erich

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×