Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Discount Coupon Codes


kgt

Recommended Posts

Ok, I have looked through a ton of pages and I haven't seen anyone else with this issue.

 

I am having a problem where I keep getting redirected to the login page when I use some of my coupon codes. 1 of the coupons I have set up works fine and takes you to the confirmation page as it should. For all the rest of the coupons this is what happens:

- customer adds something to cart

- customer clicks checkout and is taken to the login page

- customer logs in and is taken to checkout_shipping

- customer clicks continue and is taken to checkout_payment

- customer chooses payment type and enters coupon code

- when they click continue they are logged off and taken back to the login page. no errors are given.

 

the same thing happens if i enter an incorrect coupon code. i have checked to make sure that the coupons are all in the database.

 

any suggestions?

 

I tested this a little further and found out some interesting facts. Coupons work as long as they are for a total of 15% off or less. That is true whether it is percentage or fixed.

 

For example, if I enter 15% off, the coupon works fine. If I change that to 20% off I get logged off and taken to login.php.

 

Also if 15% off the subtotal = $8.85 -> If I set a fixed amount of $8.00 the coupon works just fine, but if I change it to $9.00, it doesn't work anymore.

 

Any help is appreciated. Thank you!

Link to comment
Share on other sites

Hi There,

 

I had a look through the documentation and other posts and could not find any similar problems to mine. I would really appreciate any help on this one. I have tried fixing it myself and had no luck (I stink at PHP).

 

Basically there are two things that do not work at the moment. 100% shipping coupons are 10% less than they should be and exclusions do not seem to work with shipping coupons.

 

If you have a look at the example bellow for a 100% shipping coupon the coupon is for 17.73 and not 19.50. If I change the coupon to be 110% then the final total is correct except the GST (sales tax) is out.

 

I have included examples and debugging info bellow. Thanks heaps to anyone that can help.

 

Regards

 

Jim

 

This is how it appears at the moment:

1 Item: $1,314.50

 

Courier: $19.50

Discount Coupon 8JAALB applied: -$17.73

Total: $1,316.27

GST: $121.27

 

If I set the coupon to 110% the total is correct but the tax (GST) is out:

1 Item: $1,314.50

Courier: $19.50

Discount Coupon 8JASALB applied: -$19.50

Total: $1,314.50

GST: $121.27

 

 

This is how it should be:

1 Item: $1,314.50

 

Courier: $19.50

Discount Coupon 8JAALB applied: -$19.50

Total: $1,314.50

GST: $119.50

 

Here are a few notes that may be useful (not the same transaction as above):

 

[coupon] => Array

(

[coupons_id] => 8JAALB

[coupons_description] => Free Shipping

[coupons_discount_amount] => 1.100000000000

[coupons_discount_type] => shipping

[coupons_date_start] =>

[coupons_date_end] => 2008-08-31 00:00:00

[coupons_max_use] => 0

[coupons_min_order] => 0.0000

[coupons_min_order_type] => price

[coupons_number_available] => 0

)

 

[applied_discount] => Array

(

[GST] => 0

[shipping] => 19.503

)

 

[cart_info] => Array

(

[valid_products] => Array

(

[count] => 2

[line_items] => 1

[total] => 552.298

)

 

[total_products] => Array

(

[count] => 3

[line_items] => 2

[total] => 1747.298

)

[discount_tax] => Array

(

[GST] => 0

)

 

[coupon] => discount_coupon Object

(

[messages] => Array

(

[debug] => Array

(

[0] => INFO: DISPLAY_PRICE_WITH_TAX = true

[1] => INFO: MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING = false

[2] => INFO: MODULE_SHIPPING_TABLE_STATUS = True

[3] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_STATUS = true

[4] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_SORT_ORDER = 2.5

[5] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_TYPE = true

[6] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL = true

[7] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_TAX = Display discount with discounted tax applied

[8] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_EXCLUDE_SPECIALS = true

[9] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_RANDOM_CODE_LENGTH = 8

[10] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_LINES = false

[11] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_ALLOW_NEGATIVE = false

[12] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_USE_LANGUAGE_FILE = false

[13] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_CONFIG = Discount Coupon

 applied

[14] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG = true

[15] => INFO: Product failed manufacturer exclusion check

[16] => INFO: Product failed manufacturer exclusion check

[17] => INFO: Excluded product 9572. Discount of 0 not applied.

[18] => INFO: Applied tax of 10 to: 0

[19] => INFO: Tax not applied to product 9572: 0

[20] => INFO: Discount of 0 applied to product 9572 ($1195).

[21] => INFO: Applied tax of 10 to: 1314.5

[22] => INFO: Calculating tax on 1314.5. Displayed price 1314.5.

[23] => INFO: Product 9533 passed exclusion check. Discount 0 applied. (shipping)

[24] => INFO: Applied tax of 10 to: 0

[25] => INFO: Tax not applied to product 9533: 0

[26] => INFO: Discount of 0 applied to product 9533 ($552.298).

[27] => INFO: Applied tax of 10 to: 303.76

[28] => INFO: Calculating tax on 607.52. Displayed price 607.52.

[29] => INFO: Shipping Discount of 19.503 applied.

)

 

)

Link to comment
Share on other sites

is there a way to create a coupon that includes both free shipping and a discount off of the order?

Edited by stevelucky
Link to comment
Share on other sites

Thanks allaboutwicker - :thumbsup:

 

I gave the fixes in your code a try, still no dice though. It isn't working properly on the live site at the moment either (it's one of the glitches I'm working on with the re-build).

 

I will try printing out some debug reports and see if I can learn anything of interest :)

 

 

 

Hi TracyS,

 

I don't know if this will help as it appears we have some different fixes or contribs installed, but I will post my code of the same area in that file here and you can compare to see if you think something might help:

~Tracy
 

Link to comment
Share on other sites

Thanks allaboutwicker - :thumbsup:

 

I gave the fixes in your code a try, still no dice though. It isn't working properly on the live site at the moment either (it's one of the glitches I'm working on with the re-build).

 

I will try printing out some debug reports and see if I can learn anything of interest :)

 

I see from your contribution list that you use the STS template contrib. I have not tried that one yet and for the main reason that it seems to cause a lot of hard times getting other contribs to work from what I have read. I may be wrong, but that is my hunch as to what is giving you grief. Have you checked that thread for answers to some of your problems?

Link to comment
Share on other sites

I see from your contribution list that you use the STS template contrib. I have not tried that one yet and for the main reason that it seems to cause a lot of hard times getting other contribs to work from what I have read. I may be wrong, but that is my hunch as to what is giving you grief. Have you checked that thread for answers to some of your problems?

 

If I turn off STS I still have the same issue - so I know it isn't from STS ;)

 

What I have figured out thus far is this:

The function that determines whether or not the new subtotal will change the shipping charges (both for free shipping and for table rate) is functioning. It correctly brings me back to the checkout_shipping.php page if the new subtotal should change my shipping choice. It also functions correctly with a discount that does not change my shipping charges and with no coupon applied.

 

The problem that is happening is that the checkout_shipping.php page does not know what new shipping options to present. So, let's say for example, that my table rate has $8.95 shipping for orders over $35 and my order is $40. I apply my coupon for a 15% discount and my order drops to $34 which is below the $35 so it correctly redirects me to checkout_shipping.php with a message stating "Your calculated shipping charges have changed".

 

Here is where the fun begins - the only option for me to choose is the $8.95 - it didn't pull through the new subtotal to give me the correct option of $6.95. Being all I can choose is the $8.95 it puts me into a perpetual loop of simply reloading the checkout_shipping.php with the error message.

 

Any thoughts on how to cause the new subtotal to carry through and create new shipping options when checkout_shipping.php loads up?

~Tracy
 

Link to comment
Share on other sites

WOOHOO!!! In case anyone else has this problem - I changed the following three files to match Kristen's 3.3 version:

 

catalog/includes/classes/discount_coupon.php

catalog/includes/classes/order.php

catalog/includes/modules/shipping/table.php

 

This worked great and did not require any other updates or patches. That's not to say it will solve the problem for everyone - but at least for me it worked wonderfully!!

 

Now to just figure out how to tell it to give a different error message depending on if it's a free shipping or a table rate shipping that has changed :thumbsup:

 

If I turn off STS I still have the same issue - so I know it isn't from STS ;)

 

What I have figured out thus far is this:

The function that determines whether or not the new subtotal will change the shipping charges (both for free shipping and for table rate) is functioning. It correctly brings me back to the checkout_shipping.php page if the new subtotal should change my shipping choice. It also functions correctly with a discount that does not change my shipping charges and with no coupon applied.

 

The problem that is happening is that the checkout_shipping.php page does not know what new shipping options to present. So, let's say for example, that my table rate has $8.95 shipping for orders over $35 and my order is $40. I apply my coupon for a 15% discount and my order drops to $34 which is below the $35 so it correctly redirects me to checkout_shipping.php with a message stating "Your calculated shipping charges have changed".

 

Here is where the fun begins - the only option for me to choose is the $8.95 - it didn't pull through the new subtotal to give me the correct option of $6.95. Being all I can choose is the $8.95 it puts me into a perpetual loop of simply reloading the checkout_shipping.php with the error message.

 

Any thoughts on how to cause the new subtotal to carry through and create new shipping options when checkout_shipping.php loads up?

~Tracy
 

Link to comment
Share on other sites

I am almost there! I've not been able to find a way to differentiate if the recalc shipping is due to a free shipping or a table rate recalculation, so I just made my one error message generic enough to work for both.

 

The issue I am left with now has to do with the Free Shipping with Minimum Amount contrib and DCC. Let's say I am using table rate shipping and my coupon changes my shipping option - the process that follows is:

 

redirect to checkout_shipping.php with error message to select new shipping option

select the shipping option, continue to checkout_payment.php where I REMOVE the coupon code

redirected to checkout_shipping.php as removing the code has again forced me to re-select my shipping

 

That is how it is supposed to work and does work for the table rate.

 

For Free Shipping with Minimum Amount I have it correctly redirecting me when the discount drops me below the minimum amount to qualify for free shipping. But if I remove the coupon code after choosing a new shipping method (which is a table rate method) it allows me to go through to checkout_confirmation.php rather than redirecting me to checkout_shipping.php to be able to select the free shipping option once again (since I would now qualify again after removing my coupon code).

 

I'm not sure what I need to edit for the Free Shipping section to recognize that it should re-offer the free shipping option if the coupon is removed.

 

This is in my checkout_confirmation.php just above the //load the selected shipping module bit:

//BOF Discount Coupons
 if( tep_not_null( $coupon ) && is_object( $order->coupon ) ) { //if they have entered something in the coupon field
$order->coupon->verify_code();
if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG != 'true' ) {
	  if( !$order->coupon->is_errors() ) { //if we have passed all tests (no error message), make sure we still meet free shipping requirements, if any
		  if( $order->coupon->is_recalc_shipping() ) tep_redirect( tep_href_link( FILENAME_CHECKOUT_SHIPPING, 'error_message=' . urlencode( ENTRY_DISCOUNT_COUPON_SHIPPING_CALC_ERROR ), 'SSL' ) ); //redirect to the shipping page to reselect the shipping method
	  } else {
		  if( tep_session_is_registered('coupon') ) tep_session_unregister('coupon'); //remove the coupon from the session
		  tep_redirect( tep_href_link( FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode( implode( ' ', $order->coupon->get_messages() ) ), 'SSL' ) ); //redirect to the payment page
	  }
}
} else { //if the coupon field is empty, unregister the coupon from the session
	if( tep_session_is_registered('coupon') ) { //we had a coupon entered before, so we need to unregister it
  tep_session_unregister('coupon');
  //now check to see if we need to recalculate shipping:
  require_once( DIR_WS_CLASSES.'discount_coupon.php' );
  if( discount_coupon::is_recalc_shipping() ) tep_redirect( tep_href_link( FILENAME_CHECKOUT_SHIPPING, 'error_message=' . urlencode( ENTRY_DISCOUNT_COUPON_SHIPPING_CALC_ERROR ), 'SSL' ) ); //redirect to the shipping page to reselect the shipping method
}
}
//EOF Discount Coupons

 

This is in my includes/classes/discount_coupon.php

	function is_recalc_shipping() {
  global $order, $language;

  //calculate the order total:
  $order_total = $order->info['total'] - $order->info['shipping_cost'];
  if( DISPLAY_PRICE_WITH_TAX != 'true' ) $order_total -= $order->info['tax'];

  //check if there is free shipping
		if( MODULE_SHIPPING_FREEAMOUNT_STATUS == 'True' ) {
			include( DIR_WS_LANGUAGES.$language.'/modules/shipping/freeamount.php' );
			//if free shipping is enabled, make sure the discount does not bring the order total below free shipping limit
			if( $order->info['shipping_cost'] == MODULE_SHIPPING_FREEAMOUNT_COST) { //if free shipping is the selected shipping method
				if( ( $order->info['total'] - $order->info['shipping_cost'] ) < MODULE_SHIPPING_FREEAMOUNT_AMOUNT ) { //if the discount lowers the total below the free shipping limit
					return true;
				}
			}
		}else if( MODULE_SHIPPING_WFREEAMOUNT_STATUS == 'True' ) {
			include( DIR_WS_LANGUAGES.$language.'/modules/shipping/wfreeamount.php' );
			//if free shipping is enabled, make sure the discount does not bring the order total below free shipping limit
			if( $order->info['shipping_cost'] == MODULE_SHIPPING_WFREEAMOUNT_COST ) { //if free shipping is the selected shipping method
				if( ( $order->info['total'] - $order->info['shipping_cost'] ) < MODULE_SHIPPING_WFREEAMOUNT_AMOUNT ) { //if the discount lowers the total below the free shipping limit
					return true;
				}
			}
		}

	//check if table rate shipping has changed
	if( strtolower(MODULE_SHIPPING_TABLE_STATUS) == 'true' ) {
	include( DIR_WS_LANGUAGES.$language.'/modules/shipping/table.php' );
	if( substr($order->info['shipping_method'], 0, strlen(MODULE_SHIPPING_TABLE_TEXT_TITLE)) == MODULE_SHIPPING_TABLE_TEXT_TITLE && MODULE_SHIPPING_TABLE_MODE == 'price' ) {
	  $table_cost = split( "[:,]", MODULE_SHIPPING_TABLE_COST );
	  for( $i = 0; $i < count( $table_cost ); $i += 2 ) {
		if( $order_total <= $table_cost[$i] ) {
		  $shipping = $table_cost[$i+1];
		  break;
		}
	  }
	  if( $order->info['shipping_cost'] != $shipping ) { //if the discount lowers the total below the table rate
		return true;
	  }
	}
  }

  return false;
}

 

Is there somewhere else I should be looking for where I need to edit the code to re-check when a coupon is unregistered from the session to see if the order re-qualifies for free shipping?

 

TIA ;)

 

 

WOOHOO!!! In case anyone else has this problem - I changed the following three files to match Kristen's 3.3 version:

 

catalog/includes/classes/discount_coupon.php

catalog/includes/classes/order.php

catalog/includes/modules/shipping/table.php

 

This worked great and did not require any other updates or patches. That's not to say it will solve the problem for everyone - but at least for me it worked wonderfully!!

 

Now to just figure out how to tell it to give a different error message depending on if it's a free shipping or a table rate shipping that has changed :thumbsup:

~Tracy
 

Link to comment
Share on other sites

Is there a way to have the discount applied to only the product subtotal? When I use a coupon for $100 off, it adds the subtotal and the shipping and then applies the $100 discount. But what if I want the money for shipping? I want the discount to be only applied to the product cost.

 

I have been reading a lot of posts and havent seen this addressed, so sorry if i am asking a redundant question if it has been...

Link to comment
Share on other sites

Is there a way to have the discount applied to only the product subtotal? When I use a coupon for $100 off, it adds the subtotal and the shipping and then applies the $100 discount. But what if I want the money for shipping? I want the discount to be only applied to the product cost.

 

I have been reading a lot of posts and havent seen this addressed, so sorry if i am asking a redundant question if it has been...

 

I'm not sure how to do the math in php to change how a discount is calculated - I thought it was on subtotal though (but I could be wrong) maybe double check your files with a file comparison program (like winmerge) with the original installation files.

 

Another option - if you do not want to allow a negative amount (meaning I put $50 of products into the cart and use a $100 coupon, thereby getting a $50 credit) you can set a minimum dollar amount when you create your coupon. This way, you can state that there needs to be a minimum of $100 worth of product in the cart in order to use the coupon for $100 off.

~Tracy
 

Link to comment
Share on other sites

PLEASE CAN SOME ONE HELP, IM PULLING MY HAIR OUT!!!!

 

I have installed this suberb contrib everything works except the totals!!!

 

Here are the totals

 

Sub-Total Excl.: £72.03

Discount Applied 10%: £8.32

Tax UK: £11.15

(Shipping to United Kingdom (by weight) : 3 Kg(s)): £9.99

Total: £86.09

 

 

The tax should be £12.60

 

PLEASE HELP I HAVE TRIED EVERYTHING

Link to comment
Share on other sites

PLEASE CAN SOME ONE HELP, IM PULLING MY HAIR OUT!!!!

 

I have installed this suberb contrib everything works except the totals!!!

 

Here are the totals

 

Sub-Total Excl.: £72.03

Discount Applied 10%: £8.32

Tax UK: £11.15

(Shipping to United Kingdom (by weight) : 3 Kg(s)): £9.99

Total: £86.09

The tax should be £12.60

 

PLEASE HELP I HAVE TRIED EVERYTHING

 

It looks like your 10% is coming off of the tax as well as the subtotal. 72.03 + 11.15 = 83.18 x 10% = 8.32 off

 

Is that how you wanted it? I will have to check how mine is set up and get back to you. It has been a while since I set mine up.

Link to comment
Share on other sites

It looks like your 10% is coming off of the tax as well as the subtotal. 72.03 + 11.15 = 83.18 x 10% = 8.32 off

 

Is that how you wanted it? I will have to check how mine is set up and get back to you. It has been a while since I set mine up.

 

 

Hi

 

No not really i would rather it just deducted 10% off the total price rather than everything, i have looked over the code but i am unsuccessful in getting it to do that, any help is really aprechiated.

 

I also tried messing around with how the order totals are in order but his makes no difference at all.

Link to comment
Share on other sites

Hi Simon, Sorry I am not one of those oscommerce Gurus. More like a learnin from doin, but I am trying to help. Anyway, I am posting another screen shot of my admin page with the settings shown as this might have something to do with it:

 

Screen Shot Not sure but compare mine to yours and see if they are the same. Notice that I have Display subtotal with applied discount: false and Display tax in discount line: None and then I have them set up in a certain order to come up on the customer screen.

 

I do not have a good memory and it has been a while since I installed this, but I seem to recall that I had to play around with these settings a bit until it worked out correctly.

 

Hope this helps or if not that one of those Gurus will find it and come up with a solution.

Link to comment
Share on other sites

Anyone encounter this problem?

 

Fatal error: Cannot redeclare class table in /home/wmwoo/public_html/eshop/includes/modules/shipping/table.php on line 13

 

Pls advice how to resolve this! I followed what has highlighted in the instruction, but I still encounter the problem.

 

Thanks

Link to comment
Share on other sites

Anyone encounter this problem?

 

Fatal error: Cannot redeclare class table in /home/wmwoo/public_html/eshop/includes/modules/shipping/table.php on line 13

 

Pls advice how to resolve this! I followed what has highlighted in the instruction, but I still encounter the problem.

 

Thanks

 

I found this thread:

 

http://www.oscommerce.com/forums/index.php?showtopic=70852

 

Hope that helps!

Link to comment
Share on other sites

Hello Everyone,

 

I could use some help with this contributions. I originally received the lonig.php could not be found error. I was able to resolve that with the patch but I am now getting...

 

1146 - Table 'testcatalog.TABLE_CONFIGURATION' doesn't exist

 

select configuration_key as cfgKey, configuration_value as cfgValue from TABLE_CONFIGURATION

 

[TEP STOP]

 

 

Any help on this would be greatly appreciated

Link to comment
Share on other sites

This is probably a stupid question, but I haven't installed a contribution for this program (or if I did, it was a VERY long time ago) and I don't remember doing it.....

Anyway, I want this contribution, but when I click on the contribution, it lists about 50 gazillion links---the first one from way back in like 2005 and then many updated things since then to fix bugs and whatever. I am wondering if I just click on the top item to download, am I downloading a "fix" to a problem or am I downloading the entire contribution with the latest fixes?

Thanks for any help!

Link to comment
Share on other sites

I believe Discount Coupon Codes 3.31 is the most recent full package. If you click on the little "+" signs next to each download title you can read about each one available and find which one's are full packages and which one's are updates / fixes that just include files relevent to their fix or update :thumbsup:

 

This is probably a stupid question, but I haven't installed a contribution for this program (or if I did, it was a VERY long time ago) and I don't remember doing it.....

Anyway, I want this contribution, but when I click on the contribution, it lists about 50 gazillion links---the first one from way back in like 2005 and then many updated things since then to fix bugs and whatever. I am wondering if I just click on the top item to download, am I downloading a "fix" to a problem or am I downloading the entire contribution with the latest fixes?

Thanks for any help!

~Tracy
 

Link to comment
Share on other sites

Still looking for some ideas or assistance with this one :blush:

 

The issue I am left with now has to do with the Free Shipping with Minimum Amount contrib and DCC. Let's say I am using table rate shipping and my coupon changes my shipping option - the process that follows is:

 

redirect to checkout_shipping.php with error message to select new shipping option

select the shipping option, continue to checkout_payment.php where I REMOVE the coupon code

redirected to checkout_shipping.php as removing the code has again forced me to re-select my shipping

 

That is how it is supposed to work and does work for the table rate.

 

For Free Shipping with Minimum Amount I have it correctly redirecting me when the discount drops me below the minimum amount to qualify for free shipping. But if I remove the coupon code after choosing a new shipping method (which is a table rate method) it allows me to go through to checkout_confirmation.php rather than redirecting me to checkout_shipping.php to be able to select the free shipping option once again (since I would now qualify again after removing my coupon code).

 

I'm not sure what I need to edit for the Free Shipping section to recognize that it should re-offer the free shipping option if the coupon is removed.

 

This is in my checkout_confirmation.php just above the //load the selected shipping module bit:

//BOF Discount Coupons
 if( tep_not_null( $coupon ) && is_object( $order->coupon ) ) { //if they have entered something in the coupon field
$order->coupon->verify_code();
if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG != 'true' ) {
	  if( !$order->coupon->is_errors() ) { //if we have passed all tests (no error message), make sure we still meet free shipping requirements, if any
		  if( $order->coupon->is_recalc_shipping() ) tep_redirect( tep_href_link( FILENAME_CHECKOUT_SHIPPING, 'error_message=' . urlencode( ENTRY_DISCOUNT_COUPON_SHIPPING_CALC_ERROR ), 'SSL' ) ); //redirect to the shipping page to reselect the shipping method
	  } else {
		  if( tep_session_is_registered('coupon') ) tep_session_unregister('coupon'); //remove the coupon from the session
		  tep_redirect( tep_href_link( FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode( implode( ' ', $order->coupon->get_messages() ) ), 'SSL' ) ); //redirect to the payment page
	  }
}
} else { //if the coupon field is empty, unregister the coupon from the session
	if( tep_session_is_registered('coupon') ) { //we had a coupon entered before, so we need to unregister it
  tep_session_unregister('coupon');
  //now check to see if we need to recalculate shipping:
  require_once( DIR_WS_CLASSES.'discount_coupon.php' );
  if( discount_coupon::is_recalc_shipping() ) tep_redirect( tep_href_link( FILENAME_CHECKOUT_SHIPPING, 'error_message=' . urlencode( ENTRY_DISCOUNT_COUPON_SHIPPING_CALC_ERROR ), 'SSL' ) ); //redirect to the shipping page to reselect the shipping method
}
}
//EOF Discount Coupons

 

This is in my includes/classes/discount_coupon.php

	function is_recalc_shipping() {
  global $order, $language;

  //calculate the order total:
  $order_total = $order->info['total'] - $order->info['shipping_cost'];
  if( DISPLAY_PRICE_WITH_TAX != 'true' ) $order_total -= $order->info['tax'];

  //check if there is free shipping
		if( MODULE_SHIPPING_FREEAMOUNT_STATUS == 'True' ) {
			include( DIR_WS_LANGUAGES.$language.'/modules/shipping/freeamount.php' );
			//if free shipping is enabled, make sure the discount does not bring the order total below free shipping limit
			if( $order->info['shipping_cost'] == MODULE_SHIPPING_FREEAMOUNT_COST) { //if free shipping is the selected shipping method
				if( ( $order->info['total'] - $order->info['shipping_cost'] ) < MODULE_SHIPPING_FREEAMOUNT_AMOUNT ) { //if the discount lowers the total below the free shipping limit
					return true;
				}
			}
		}else if( MODULE_SHIPPING_WFREEAMOUNT_STATUS == 'True' ) {
			include( DIR_WS_LANGUAGES.$language.'/modules/shipping/wfreeamount.php' );
			//if free shipping is enabled, make sure the discount does not bring the order total below free shipping limit
			if( $order->info['shipping_cost'] == MODULE_SHIPPING_WFREEAMOUNT_COST ) { //if free shipping is the selected shipping method
				if( ( $order->info['total'] - $order->info['shipping_cost'] ) < MODULE_SHIPPING_WFREEAMOUNT_AMOUNT ) { //if the discount lowers the total below the free shipping limit
					return true;
				}
			}
		}

	//check if table rate shipping has changed
	if( strtolower(MODULE_SHIPPING_TABLE_STATUS) == 'true' ) {
	include( DIR_WS_LANGUAGES.$language.'/modules/shipping/table.php' );
	if( substr($order->info['shipping_method'], 0, strlen(MODULE_SHIPPING_TABLE_TEXT_TITLE)) == MODULE_SHIPPING_TABLE_TEXT_TITLE && MODULE_SHIPPING_TABLE_MODE == 'price' ) {
	  $table_cost = split( "[:,]", MODULE_SHIPPING_TABLE_COST );
	  for( $i = 0; $i < count( $table_cost ); $i += 2 ) {
		if( $order_total <= $table_cost[$i] ) {
		  $shipping = $table_cost[$i+1];
		  break;
		}
	  }
	  if( $order->info['shipping_cost'] != $shipping ) { //if the discount lowers the total below the table rate
		return true;
	  }
	}
  }

  return false;
}

 

Is there somewhere else I should be looking for where I need to edit the code to re-check when a coupon is unregistered from the session to see if the order re-qualifies for free shipping?

 

TIA ;)

~Tracy
 

Link to comment
Share on other sites

I'm not sure how to do the math in php to change how a discount is calculated - I thought it was on subtotal though (but I could be wrong) maybe double check your files with a file comparison program (like winmerge) with the original installation files.

 

Another option - if you do not want to allow a negative amount (meaning I put $50 of products into the cart and use a $100 coupon, thereby getting a $50 credit) you can set a minimum dollar amount when you create your coupon. This way, you can state that there needs to be a minimum of $100 worth of product in the cart in order to use the coupon for $100 off.

 

No, everything works as it should. I dont get negative amounts if the coupon is larger than the subtotal.

 

 

BUT if the coupon is larger than the subtotal, I dont want the coupon to affect the shipping price.

 

Here is an example of what happens:

 

$50 Subtotal

$10 Shipping charge

-$100 Coupon

-------------

$0 TOTAL

 

 

Here is an example of what I would like to happen:

 

$50 Subtotal

$10 Shipping charge

-$100 Coupon

-------------

$10 TOTAL

 

As you can see it would be nice if it were possible to exclude the ship price when the coupon is applied, maybe this could be an option when setting up the coupon.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...