Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

kgt

[Contribution] Discount Coupon Codes

Recommended Posts

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.

 

 

This is a server problem:

 

http://www.google.com/search?hl=en&lr=...amp;btnG=Search


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites

Silly question time from me.

 

Do I need to install the original V2 verison and then the Bug fix version. The admin area is not in the bugfix zip.

 

Also can you have a non expirery discount code (i.e. be used as many times as wanted, by as many people as want to use it)

Share this post


Link to post
Share on other sites

I have just installed this contribution and think it well written. but i have a small problem. can anyone tell me how to fix it?

the issue is that i want my customers to use a fixed coupon as in say $20 is applied to all orders greater than $25 , but if order is less than $25 then coupon can not be applied.

i tried several ways to acheive this but it seems the coupon gets applied regardless of the order being less than $25 which results in an undesirable negative order total. any help or advise will be well apreciated.

Share this post


Link to post
Share on other sites

I installed this contrib today but I cannot see where I can add the coupon code when placing orders.

 

I have double and triple checked to make sure all the files have been edited and installed correctly. All the Admin side is working well, just the shop side.

 

I am using Fast Easy Checkout, is this compatible with the Discounts Contrib?

Share this post


Link to post
Share on other sites

With the help of Boxtel I managed to get it working. I added the same code from checkout_payment.php into checkout_shipping.php and it seems to be working with initial tests.

Share this post


Link to post
Share on other sites
Silly question time from me.

 

Do I need to install the original V2 verison and then the Bug fix version. The admin area is not in the bugfix zip.

 

Also can you have a non expirery discount code (i.e. be used as many times as wanted, by as many people as want to use it)

 

The bug fix is for version 2, so it means it's just a fix for version 2 release. So you need version 2 then apply the bugfix.

 

Coupons need not expire. Read the manual for more help on what the settings are. You can find it as a link from the top right corner of the coupons admin.


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites
I have just installed this contribution and think it well written. but i have a small problem. can anyone tell me how to fix it?

the issue is that i want my customers to use a fixed coupon as in say $20 is applied to all orders greater than $25 , but if order is less than $25 then coupon can not be applied.

i tried several ways to acheive this but it seems the coupon gets applied regardless of the order being less than $25 which results in an undesirable negative order total. any help or advise will be well apreciated.

 

Make sure you have the bugfixes applied, and see this post:

 

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


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites

Version 2.1 is up with compiled bugfixes and one new feature.

 

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

 

Bug Fixes:

* Replaced tep_db_prepare_input() with tep_db_input() in includes/classes/discount_coupon.php to correctly sanitize string for database query.

* Max_use, min_order, number_available checks did not work with update to 2.0 because of a missing line.

* Error message for max_use would not display because it was not being saved as a object variable.

* Global currencies variable was not declared in function to check min_order so resulted in an error.

* If discount is more than min_order, do not allow applied discount to exceed the products price to prevent negative order totals.

* Unregister the coupon session variable when logging off.

 

Other changes:

* Added configuration option to select whether to use language files for order total line display or to use the module configuration field. This is needed for shops using multiple languages that wish to display the order total line formatted for each language.

 

Also, a report that works with the 2.* versions is up (also included with the 2.1 version).


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites

Anyone else getting

 

1054 - Unknown column 'cd.coupons_date_end' in 'order clause'

select * from discount_coupons cd order by cd.coupons_date_end, coupons_date_start limit 0, 21

[TEP STOP]

 

I just tried upgrading? Am i missing some sql changes?

Share this post


Link to post
Share on other sites
Anyone else getting

 

1054 - Unknown column 'cd.coupons_date_end' in 'order clause'

select * from discount_coupons cd order by cd.coupons_date_end, coupons_date_start limit 0, 21

[TEP STOP]

 

I just tried upgrading? Am i missing some sql changes?

 

 

I think maybe you missed upgrading to 2.0. 2.1 assumes you did the 2.0 upgrade.

 

You need to perform the following queries:

 

ALTER TABLE discount_coupons CHANGE date_start coupons_date_start DATETIME DEFAULT NULL;
ALTER TABLE discount_coupons CHANGE date_end coupons_date_end DATETIME DEFAULT NULL;
ALTER TABLE discount_coupons CHANGE max_use coupons_max_use INT(3) NOT NULL DEFAULT 0;
ALTER TABLE discount_coupons CHANGE max_order coupons_max_order DECIMAL(15,4) NOT NULL DEFAULT '0.0000';
ALTER TABLE discount_coupons CHANGE number_available coupons_number_available INT(3) DEFAULT 0 NOT NULL;
ALTER TABLE discount_coupons ADD COLUMN coupons_max_order DECIMAL(15,4)  DEFAULT '0.0000' NOT NULL AFTER coupons_min_order;

Also check you have version 2.0 already installed.


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites

Hello,

I have installed the coupon report and everything seems to work properly except for 1 item. On the report page, "All coupons", I click on the % Discount, Global Number Available or Number Used columns to drill down into the report deeper. When that report page appears, the column for Customer Name is always empty.

 

Was the intent to have the name appear in this column? Please advise.

Share this post


Link to post
Share on other sites

Hi,

 

I've installed the contrib, but when I get to checkout_payment.php and click "Continue", the next page is blank. It's blank whether I enter a coupon or not. Also, I removed all coupons, and didn't enter one, still blank. The only way to fix my e-com is by disabling the module in the admin.

 

Any suggestions?

 

Thanks,

Mike

Share this post


Link to post
Share on other sites
Hi,

 

I've installed the contrib, but when I get to checkout_payment.php and click "Continue", the next page is blank. It's blank whether I enter a coupon or not. Also, I removed all coupons, and didn't enter one, still blank. The only way to fix my e-com is by disabling the module in the admin.

 

Any suggestions?

 

Thanks,

Mike

 

You've probably got a fatal error and your host has display_errors turned off. You can usually turn them on to find out what the error is by adding these two lines to the top of includes/application_top.php:

 

ini_set( 'error_reporting', 'on' );

ini_set( 'display_errors', 1 );

 

 

Once you know what the error is, it should give more information as to what the problem is.


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites
Hello,

I have installed the coupon report and everything seems to work properly except for 1 item. On the report page, "All coupons", I click on the % Discount, Global Number Available or Number Used columns to drill down into the report deeper. When that report page appears, the column for Customer Name is always empty.

 

Was the intent to have the name appear in this column? Please advise.

 

The name should appear and as far as I know, it works.

 

You can try replacing

 

<td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS, 'action=edit&oID=' . $coupons['orders_id'] . '&action=edit') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . $coupons['customers_name']; ?></td>

with

<td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS, 'action=edit&oID=' . $coupons['orders_id'] . '&action=edit') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . tep_customers_name($HTTP_GET_VARS['custID']); ?></td>

in admin/stats_discount_coupons.php on line 83.

 

If that doesn't work, then I'd need some more information.


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites

Kristen,

 

I made the change as suggested and still saw no Customer Names. This made no sense as I now see where you were retrieving the data from. So, I looked into our tables and found the issue. We periodically dump older orders from the online tables due to volume. The coupon code I was using had not been used since this last dump and consequently, the orders did not exist to get the cus name from. I checked with some more recent customer orders and other discount codes and everything is working as it should.

 

Sorry for the false alarm.

Share this post


Link to post
Share on other sites
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.

 

the fix amount discount works fine, but the percentage discount is weird. it seems like it is always taking $600 as the subtotal, like if I enter a 15% off coupon, it will take $90 off and if I enter a 30% off coupon, it will take $180 off, no matter how much amount in the cart, what could be wrong? :(


slingcarrier dot com

Share this post


Link to post
Share on other sites
the fix amount discount works fine, but the percentage discount is weird. it seems like it is always taking $600 as the subtotal, like if I enter a 15% off coupon, it will take $90 off and if I enter a 30% off coupon, it will take $180 off, no matter how much amount in the cart, what could be wrong? :(

 

I know nothing about the mechanics of what's happening because you haven't provided any useful information. You're making a conjecture as to what's going wrong (order total is $600) but that may not be what's actually happening. It's kind of like saying, "well my car won't start so I must have run out of gas." There can be multiple (hidden) causes for one symptom so it's almost impossible to diagnose without more information.

 

At the very minimum, I will need to see a sample order with all the order totals. I will also need to know what entries you have in each and every field of the coupon (max use, min order, etc).


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites

Hi KGT,

 

I added the code you mentioned and am getting this error:

 

Fatal error: Call to a member function on a non-object in /home/httpd/vhosts/pathtodomain/httpdocs/products/checkout_confirmation.php on line 58

 

Here is part of what is on that page, not sure what to do now though. (i numbered the lines)

 

46		//kgt - discount coupons
47	  if (!tep_session_is_registered('coupon')) tep_session_register('coupon');
48	  if (tep_not_null($HTTP_POST_VARS['coupon'])) {
49		  //this needs to be set before the order object is created, but we must process it after
50		$coupon = tep_db_prepare_input($HTTP_POST_VARS['coupon']);
51	  }
52	  //end kgt - discount coupons
53
54
55   require(DIR_WS_CLASSES . 'order.php');
56  $order = new order;
57 
58  $payment_modules->update_status();

Share this post


Link to post
Share on other sites
I think maybe you missed upgrading to 2.0. 2.1 assumes you did the 2.0 upgrade.

 

You need to perform the following queries:

 

ALTER TABLE discount_coupons CHANGE date_start coupons_date_start DATETIME DEFAULT NULL;
ALTER TABLE discount_coupons CHANGE date_end coupons_date_end DATETIME DEFAULT NULL;
ALTER TABLE discount_coupons CHANGE max_use coupons_max_use INT(3) NOT NULL DEFAULT 0;
ALTER TABLE discount_coupons CHANGE max_order coupons_max_order DECIMAL(15,4) NOT NULL DEFAULT '0.0000';
ALTER TABLE discount_coupons CHANGE number_available coupons_number_available INT(3) DEFAULT 0 NOT NULL;
ALTER TABLE discount_coupons ADD COLUMN coupons_max_order DECIMAL(15,4)  DEFAULT '0.0000' NOT NULL AFTER coupons_min_order;

Also check you have version 2.0 already installed.

 

Attempting to run the SQL changes above in a 1.4 to 2.0 and I get the error that the 'date_start' colum does not exist. What am I missing?

Share this post


Link to post
Share on other sites
Attempting to run the SQL changes above in a 1.4 to 2.0 and I get the error that the 'date_start' colum does not exist. What am I missing?

 

You either already ran them or something else is going on. I can't really say without knowing what your database looks like.


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites
Hi KGT,

 

I added the code you mentioned and am getting this error:

 

Fatal error: Call to a member function on a non-object in /home/httpd/vhosts/pathtodomain/httpdocs/products/checkout_confirmation.php on line 58

 

Here is part of what is on that page, not sure what to do now though. (i numbered the lines)

 

46		//kgt - discount coupons
47	  if (!tep_session_is_registered('coupon')) tep_session_register('coupon');
48	  if (tep_not_null($HTTP_POST_VARS['coupon'])) {
49		  //this needs to be set before the order object is created, but we must process it after
50		$coupon = tep_db_prepare_input($HTTP_POST_VARS['coupon']);
51	  }
52	  //end kgt - discount coupons
53
54
55   require(DIR_WS_CLASSES . 'order.php');
56  $order = new order;
57 
58  $payment_modules->update_status();

 

I think when you added the discount coupons code, you stepped over more than you should have. That same snippet should look like this:

 

//kgt - discount coupons
 if (!tep_session_is_registered('coupon')) tep_session_register('coupon');
 if (tep_not_null($HTTP_POST_VARS['coupon'])) {
  //this needs to be set before the order object is created, but we must process it after
$coupon = tep_db_prepare_input($HTTP_POST_VARS['coupon']);
 }
 //end kgt - discount coupons

// load the selected payment module
 require(DIR_WS_CLASSES . 'payment.php');
 $payment_modules = new payment($payment);

 require(DIR_WS_CLASSES . 'order.php');
 $order = new order;

 $payment_modules->update_status();

 

You're missing these lines:

 

// load the selected payment module

require(DIR_WS_CLASSES . 'payment.php');

$payment_modules = new payment($payment);


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites

Thanks KGT, I appreciate the help. I fixed that file, but now getting this error:

 

 

Warning: main(/home/httpd/vhosts/pathtodomain/httpdocs/productsincludes/classes/discount_coupon.php): failed to open stream: No such file or directory in /home/httpd/vhosts/pathtodomain/httpdocs/products/includes/modules/order_total/ot_discount_coupon.php on line 14

 

Fatal error: main(): Failed opening required '/home/httpd/vhosts/pathtodomain/httpdocs/productsincludes/classes/discount_coupon.php' (include_path='.:/usr/share/pear') in /home/httpd/vhosts/pathtodomain/httpdocs/products/includes/modules/order_total/ot_discount_coupon.php on line 14

 

I checked it out, and all the files are uploaded though.

 

Line 14 is:

 	require_once( DIR_FS_CATALOG.DIR_WS_CLASSES.'discount_coupon.php' );

 

But that file is there too.

 

Is there supposed to be no / (slash) between the "products" and "includes" dir in those errors above?

Edited by mltgroup

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

×