Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Discount Coupon Codes


kgt

Recommended Posts

You should find many posts on this topic. It has to do with permissions on your site:

 

http://www.google.com/search?hl=en&q=I...G=Google+Search

 

Very helpful Thanks!! I just set the permissions to 444 on that file and it fixed it. I appreciate all of your help - excellent mod. It did several things I was needing it to do

Link to comment
Share on other sites

after updating my discount coupon to the latest one with all the fixes i get an error in the discount coupon report, when i enter i get this message. everything else works fine, but the discount coupon report module.

 

1054 - Unknown column 'dc.number_available' in 'field list'

 

select dc.coupons_id, dc.coupons_discount_percent, dc.number_available, COUNT(dcto.discount_coupons_to_orders_id) AS use_count from discount_coupons AS dc left join discount_coupons_to_orders AS dcto ON dc.coupons_id = dcto.coupons_id group by dc.coupons_id order by use_count desc, dc.coupons_id asc limit 0, 100

 

[TEP STOP]

Link to comment
Share on other sites

after updating my discount coupon to the latest one with all the fixes i get an error in the discount coupon report, when i enter i get this message. everything else works fine, but the discount coupon report module.

 

1054 - Unknown column 'dc.number_available' in 'field list'

 

select dc.coupons_id, dc.coupons_discount_percent, dc.number_available, COUNT(dcto.discount_coupons_to_orders_id) AS use_count from discount_coupons AS dc left join discount_coupons_to_orders AS dcto ON dc.coupons_id = dcto.coupons_id group by dc.coupons_id order by use_count desc, dc.coupons_id asc limit 0, 100

 

[TEP STOP]

 

The field names all got changed to discount_coupons_*. So just edit that file and make sure all field names have "discount_coupons_" as a prefix.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Hello,

 

I've followed all your instructions for installing both the 2.0 version as well as the "class fix" version. Everything seems to be working great other then when I try to submit a valid coupon to an order that has not met the min. order value. If I do this, I get sent to checkout_confirmation.php (normal) and the page is completely blank (no errors displayed, but obviously broken). It looks like something is breaking when the order tries to verify that min and max values are met. Can anyone offer a hand here, or maybe guide me as to where to begin looking?

 

Thanks,

N

 

PS. If you would like to see what I am talking about, feel free to check out my site at http://pyp-bomb.com and click on the "ORDER" tab on the top right. Once in, you can try coupon code "XYZTEST" (min. is set to $25, no max, discount = .05) on a test order which should not meet the $25.00 min. value.

Link to comment
Share on other sites

Please help me.... :o

 

Hi, this is my first post. I have already installed some other contributions and so far it was ok...

 

I have a serious issue with this contribution...I installed it, and it looks to be working fine (not 100% as there are some minor issues that I'll report about it later).

the thing is that now under my admin > modules > order total I'm getting this error message:

 

Fatal error: Cannot redeclare class ot_discount_coupon in bla bla bla /catalog/includes/modules/order_total/ot_discount_coupon.php on line 15

 

 

Do you know what is wrong?

 

 

Thank you very much for your help!

Edited by jokatz
Link to comment
Share on other sites

Hello,

 

I've followed all your instructions for installing both the 2.0 version as well as the "class fix" version. Everything seems to be working great other then when I try to submit a valid coupon to an order that has not met the min. order value. If I do this, I get sent to checkout_confirmation.php (normal) and the page is completely blank (no errors displayed, but obviously broken). It looks like something is breaking when the order tries to verify that min and max values are met. Can anyone offer a hand here, or maybe guide me as to where to begin looking?

 

 

Well, I looked around a bit myself and came up with at least a temporary solution. The prob is in classes/discount_coupon,php. Specifically, it is in the function check_coupons_min_order(). The last line seems to be having a problem with the whole $currencies->format... statement.

 

ORIGINAL:

if( $this->coupon['coupons_min_order'] > $subtotal ) $this->error_message[] = sprintf( ENTRY_DISCOUNT_COUPON_MIN_ERROR, $currencies->format( $this->coupon['coupons_min_order'], true, $order->info['currency'], $order->info['currency_value'] ) );

 

NEW:

if( $this->coupon['coupons_min_order'] > $subtotal ) $this->error_message[] = sprintf( ENTRY_DISCOUNT_COUPON_MIN_ERROR, (number_format($this->coupon['coupons_min_order'],2)), true, $order->info['currency'], $order->info['currency_value']);

 

I needed to get these coupons working, so, while a more elegant solution is not available, this will due.

 

If anyone has any suggestions as to how to actually fix the whole $currencies issue, please do let me know.

 

 

Thanks,

N

Link to comment
Share on other sites

Well, I looked around a bit myself and came up with at least a temporary solution. The prob is in classes/discount_coupon,php. Specifically, it is in the function check_coupons_min_order(). The last line seems to be having a problem with the whole $currencies->format... statement.

 

ORIGINAL:

if( $this->coupon['coupons_min_order'] > $subtotal ) $this->error_message[] = sprintf( ENTRY_DISCOUNT_COUPON_MIN_ERROR, $currencies->format( $this->coupon['coupons_min_order'], true, $order->info['currency'], $order->info['currency_value'] ) );

 

NEW:

if( $this->coupon['coupons_min_order'] > $subtotal ) $this->error_message[] = sprintf( ENTRY_DISCOUNT_COUPON_MIN_ERROR, (number_format($this->coupon['coupons_min_order'],2)), true, $order->info['currency'], $order->info['currency_value']);

 

I needed to get these coupons working, so, while a more elegant solution is not available, this will due.

 

If anyone has any suggestions as to how to actually fix the whole $currencies issue, please do let me know.

Thanks,

N

 

See this post:

 

http://www.oscommerce.com/forums/index.php?sho...019&st=260#

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Please help me.... :o

 

Hi, this is my first post. I have already installed some other contributions and so far it was ok...

 

I have a serious issue with this contribution...I installed it, and it looks to be working fine (not 100% as there are some minor issues that I'll report about it later).

the thing is that now under my admin > modules > order total I'm getting this error message:

 

Fatal error: Cannot redeclare class ot_discount_coupon in bla bla bla /catalog/includes/modules/order_total/ot_discount_coupon.php on line 15

Do you know what is wrong?

Thank you very much for your help!

 

The solution is outlined in the common problems text file in the zip download and in the manual. Open includes/classes/discount_coupon.php and comment out the require_once line.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

I am first timer here , I just installed the discount coupon code, and the coupon input box showed up, but when I click on "continue", I got a error message popped up

Fatal error: Cannot instantiate non-existent class: discount_coupon in /home/ing/public_html/catalog/checkout_confirmation.php on line 73

 

I upload all the files with FTP as directed, configure the module in admin panel, since I haven't used any other contributions yet. what can I do to get it straight?:(

 

can anyone here lighten me up?

slingcarrier dot com

Link to comment
Share on other sites

Hi All,

very nice addon to os commerce, i install this and it's working fine, the only issue i have is that on the checkout_confirmation.php the discount takes place but nothing shows to let the customer know that he coupon was applied ( the line that reads "coupon number bla -$", any ideas if i missed something during the installation?

Link to comment
Share on other sites

Hi All,

very nice addon to os commerce, i install this and it's working fine, the only issue i have is that on the checkout_confirmation.php the discount takes place but nothing shows to let the customer know that he coupon was applied ( the line that reads "coupon number bla -$", any ideas if i missed something during the installation?

 

 

There is a manual available as a link in the upper right corner of the coupons admin page. It also has some common problems and solutions.

 

I suspect this is a result of a non-unique sort order for the order total modules. Try going to Modules > Order Total, and make sure each module has a unique sort order.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

I am first timer here , I just installed the discount coupon code, and the coupon input box showed up, but when I click on "continue", I got a error message popped up

Fatal error: Cannot instantiate non-existent class: discount_coupon in /home/ing/public_html/catalog/checkout_confirmation.php on line 73

 

I upload all the files with FTP as directed, configure the module in admin panel, since I haven't used any other contributions yet. what can I do to get it straight?:(

 

can anyone here lighten me up?

 

Try adding this line:

 

require_once( DIR_WS_CLASSES . 'discount_coupon.php' );

 

after

 

  //kgt - discount coupons
 if( tep_not_null( $HTTP_POST_VARS['coupon'] ) ) { //if they have entered something in the coupon field

 

on line 71 in checkout_confirmation.php.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Thanks!:DI reinstalled all the files one by one now it's working for the most part!!! one more problem with coupon, I set the coupon from database directly, 15% off, but no matter what the total order amount, it always takes $90 off, sometimes the total came out negative, what could be the reason of it? is there any parameter that I set wrong?

Edited by rabbit0860

slingcarrier dot com

Link to comment
Share on other sites

If there is a value in the "Number Available" field, then that coupon code should only be able to be redeemed that number of times, correct?

 

This doesn't seem to work, because I am able to use the same coupon code as many times as I want, even if I set that number to 1.

 

I can't seem to find anything in the code that decrements that amount when a coupon is redeemed. Am I missing something?

Link to comment
Share on other sites

Thanks!:DI reinstalled all the files one by one now it's working for the most part!!! one more problem with coupon, I set the coupon from database directly, 15% off, but no matter what the total order amount, it always takes $90 off, sometimes the total came out negative, what could be the reason of it? is there any parameter that I set wrong?

 

Percentages must be entered as .15 not 15.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

If there is a value in the "Number Available" field, then that coupon code should only be able to be redeemed that number of times, correct?

 

This doesn't seem to work, because I am able to use the same coupon code as many times as I want, even if I set that number to 1.

 

I can't seem to find anything in the code that decrements that amount when a coupon is redeemed. Am I missing something?

 

There's actually an increment, not the other way around. We track the coupons that have been used, so to check number_available, we need to count the number that have been used. This is stored in the discount_coupons_to_orders table. Make sure there are entries in there for the coupon you're using. If not, then that's where the problem is.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

There's actually an increment, not the other way around. We track the coupons that have been used, so to check number_available, we need to count the number that have been used. This is stored in the discount_coupons_to_orders table. Make sure there are entries in there for the coupon you're using. If not, then that's where the problem is.

Thanks for the fast reply. I discovered that was your methodology after I made my post.

 

However, I also notice that the function check_num_available() is where that lookup takes place, and the only time that is called is in the verify_code() function. Unfortunately, I don't see any place where verify_code() is called, which probably explains why I'm able to use the same coupon more times than the number of available.

 

I added the function call to the discount_coupon class get_coupon() function and it looks like everything gets checked now.

 

function get_coupon() {
$check_code_query = tep_db_query( $sql = "SELECT coupons_discount_percent, coupons_description, coupons_max_use, coupons_min_order, coupons_max_order, coupons_number_available FROM " . TABLE_DISCOUNT_COUPONS . " WHERE coupons_id = '" . tep_db_prepare_input( $this->code ) . "'
							AND ( coupons_date_start <= CURDATE() OR coupons_date_start IS NULL )
							AND ( coupons_date_end >= CURDATE() OR coupons_date_end IS NULL )" );
if( tep_db_num_rows( $check_code_query ) != 1 ) { //if no rows are returned, then they haven't entered a valid code
	$this->error_message[] = ENTRY_DISCOUNT_COUPON_ERROR; //display the error message
} else {
	$row = tep_db_fetch_array( $check_code_query ); //since there is one record, we have a valid code
	$this->coupon = $row;

	// ADD BY MJH 09/13/06
	$this->verify_code();
	if ($this->is_errors()) {
		$this->coupon = null;
	}
	// END ADD
}
}

Link to comment
Share on other sites

Thanks for the fast reply. I discovered that was your methodology after I made my post.

 

However, I also notice that the function check_num_available() is where that lookup takes place, and the only time that is called is in the verify_code() function. Unfortunately, I don't see any place where verify_code() is called, which probably explains why I'm able to use the same coupon more times than the number of available.

 

I added the function call to the discount_coupon class get_coupon() function and it looks like everything gets checked now.

 

 

Yes, the most recent update fixes that:

 

http://www.oscommerce.com/community/contributions,4269

 

You can add the code in checkout_confirmation or in the discount_coupon class as you did to fix it.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Yes, the most recent update fixes that:

 

http://www.oscommerce.com/community/contributions,4269

 

You can add the code in checkout_confirmation or in the discount_coupon class as you did to fix it.

 

Well, I guess that's what I get for checking the support thread before checking the contributions page itself. I must have downloaded v2.0 the day before the bugfix.

 

Thanks for the help.

Link to comment
Share on other sites

Firstly, this contribution is exactly what I was looking for and everything was so easy to set up - well done and thank you!

 

Now, I need a little help - when completing checkout instead of seeing the checkout success page, I see this:

 

 

Warning: mail() [function.mail]: SMTP server response: 501 5.5.4 Invalid Address in *******\includes\classes\email.php on line 520

Warning: Cannot modify header information - headers already sent by (output started at *******\includes\classes\email.php:520) in ******\includes\functions\general.php on line 33

 

I'm not sure where to start to fix this, my store is pretty well modified, I suspect the error is in general.php rather than email.php - but being a complete beginner I don't know where to start!

 

Any suggestions would be really appreciated - let me know if I need to post the code for each or either file.

 

Thanks!

 

Nick

 

Happy Horses Supplies

Link to comment
Share on other sites

0.15 is what I entered, I don't understand why it's always -$90, no matter the subtotal is $29.95 or $125 or any other amount.. :'( someone give me a hint please

 

 

You're going to have to give more information, like the values of the other fields, a sample of your order confirmation totals (with the products prices and quantities included). It's just not possible to make a wild guess as to what the problem is.

Contributions

 

Discount Coupon Codes

Donations

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