Jump to content
kgt

[Contribution] Discount Coupon Codes

Recommended Posts

I get 2 pictures to show you my problem. Please, click the link

 

Screens of problems

 

I understand what the symptoms are, but I cannot identify the problem if you don't give me more information. You will need to tell me how you installed this. I need to know whether you have upgraded to version 1.2 at any time.

 

You can check the version of coupons.php against the most recent one. They should be the same. You need to make sure there's a value for the coupon code length in the Modules > Order Total > Discount Coupons module.


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites
I understand what the symptoms are, but I cannot identify the problem if you don't give me more information. You will need to tell me how you installed this. I need to know whether you have upgraded to version 1.2 at any time.

 

You can check the version of coupons.php against the most recent one. They should be the same. You need to make sure there's a value for the coupon code length in the Modules > Order Total > Discount Coupons module.

 

 

Sorry. Is my fault. I forgot to install the module. Everythings works now. Thank you so much and congratulations. This is the best one contribute that I saw.

 

Renato

Share this post


Link to post
Share on other sites
As long as you still go directly from checkout_shipping.php to checkout_confirmation.php, you just need to add the code from checkout_payment.php into checkout_shipping.php. The code from checkout_payment.php just displays the form field for entering the code.

 

Then change the code from checkout_confirmation to go back to the shipping page if there's an error:

 

if( count( $error_message ) > 0 ) tep_redirect( tep_href_link( FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode( implode( ' ', $error_message ) ), 'SSL' ) ); //if there was an error, redirect to the payment page

 

Change to:

 

if( count( $error_message ) > 0 ) tep_redirect( tep_href_link( FILENAME_CHECKOUT_SHIPPING, 'error_message=' . urlencode( implode( ' ', $error_message ) ), 'SSL' ) ); //if there was an error, redirect to the payment page

 

This isn't tested, so be sure to back up.

 

 

Thank you so much! It's work great now! Shows right up where I need it, thank you again :)

Share this post


Link to post
Share on other sites

Hi KGT

 

One more little thing: in the order appear this text: Discount Coupon (code) applied: (value)

 

I need to translate this words but I didn't find. Can you tell me where's?

 

Thanks

Share this post


Link to post
Share on other sites

Ok, I have still been tinkering, but no luck as of yet. I still have the code as seen below. I had posted what was on line 67 in in the admin/includes/functions/sessions.php file above and it was :

return session_start();

 

The whole file for this is posted below my errors that I am receiving. Hopefully you can spot something I dont see.

 

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /mnt/w0201/d29/s37/b0282505/www/Products/nfoscomm/catalog/admin/includes/filenames.php:58) in /mnt/w0201/d29/s37/b0282505/www/Products/nfoscomm/catalog/admin/includes/functions/sessions.php on line 67

 

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /mnt/w0201/d29/s37/b0282505/www/Products/nfoscomm/catalog/admin/includes/filenames.php:58) in /mnt/w0201/d29/s37/b0282505/www/Products/nfoscomm/catalog/admin/includes/functions/sessions.php on line 67

 

sessions.php file

 

<?php

/*

$Id: sessions.php,v 1.9 2003/06/23 01:20:05 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

if (STORE_SESSIONS == 'mysql') {

if (!$SESS_LIFE = get_cfg_var('session.gc_maxlifetime')) {

$SESS_LIFE = 1440;

}

 

function _sess_open($save_path, $session_name) {

return true;

}

 

function _sess_close() {

return true;

}

 

function _sess_read($key) {

$qid = tep_db_query("select value from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "' and expiry > '" . time() . "'");

 

$value = tep_db_fetch_array($qid);

if ($value['value']) {

return $value['value'];

}

 

return false;

}

 

function _sess_write($key, $val) {

global $SESS_LIFE;

 

$expiry = time() + $SESS_LIFE;

$value = $val;

 

$qid = tep_db_query("select count(*) as total from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'");

$total = tep_db_fetch_array($qid);

 

if ($total['total'] > 0) {

return tep_db_query("update " . TABLE_SESSIONS . " set expiry = '" . tep_db_input($expiry) . "', value = '" . tep_db_input($value) . "' where sesskey = '" . tep_db_input($key) . "'");

} else {

return tep_db_query("insert into " . TABLE_SESSIONS . " values ('" . tep_db_input($key) . "', '" . tep_db_input($expiry) . "', '" . tep_db_input($value) . "')");

}

}

 

function _sess_destroy($key) {

return tep_db_query("delete from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'");

}

 

function _sess_gc($maxlifetime) {

tep_db_query("delete from " . TABLE_SESSIONS . " where expiry < '" . time() . "'");

 

return true;

}

 

session_set_save_handler('_sess_open', '_sess_close', '_sess_read', '_sess_write', '_sess_destroy', '_sess_gc');

}

 

function tep_session_start() {

return session_start();

}

 

function tep_session_register($variable) {

return session_register($variable);

}

 

function tep_session_is_registered($variable) {

return session_is_registered($variable);

}

 

function tep_session_unregister($variable) {

return session_unregister($variable);

}

 

function tep_session_id($sessid = '') {

if ($sessid != '') {

return session_id($sessid);

} else {

return session_id();

}

}

 

function tep_session_name($name = '') {

if ($name != '') {

return session_name($name);

} else {

return session_name();

}

}

 

function tep_session_close() {

if (function_exists('session_close')) {

return session_close();

}

}

 

function tep_session_destroy() {

return session_destroy();

}

 

function tep_session_save_path($path = '') {

if ($path != '') {

return session_save_path($path);

} else {

return session_save_path();

}

}

?>

Share this post


Link to post
Share on other sites
Ok, I have still been tinkering, but no luck as of yet. I still have the code as seen below. I had posted what was on line 67 in in the admin/includes/functions/sessions.php file above and it was :

return session_start();

 

 

As I said in my first reply:

 

If uploading those files doesn't fix your problem, then you will need to post the code you have in admin/includes/filenames.php on line 67. That's the important file to see when you get an error like this.

 

Though I had a typo and quoted the wrong line number on filenames.php. Your error says 57/58.

Edited by kgt

Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites
Think you missed editing includes/database_tables.php:

You need to add this code somewhere in that file.

 

THANK YOU! That worked perfectly! GREAT contribution.

 

-Andrew

Share this post


Link to post
Share on other sites

HI, Sorry about the file, I took a guess that you had the line right and file wrong, even though you took a piece of each, Here is the admin/includes/filenames.php. The reason the number changed was that I added a space to see if it would make a difference. The only thing that confuses me here, is that the error is on the line beyond the last line?!? when I do my counting.

 

<?php

/*

$Id: filenames.php,v 1.1 2003/06/20 00:18:30 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

// define the filenames used in the project

define('FILENAME_BACKUP', 'backup.php');

define('FILENAME_BANNER_MANAGER', 'banner_manager.php');

define('FILENAME_BANNER_STATISTICS', 'banner_statistics.php');

define('FILENAME_CACHE', 'cache.php');

define('FILENAME_CATALOG_ACCOUNT_HISTORY_INFO', 'account_history_info.php');

define('FILENAME_CATEGORIES', 'categories.php');

define('FILENAME_CONFIGURATION', 'configuration.php');

define('FILENAME_COUNTRIES', 'countries.php');

define('FILENAME_CURRENCIES', 'currencies.php');

define('FILENAME_CUSTOMERS', 'customers.php');

define('FILENAME_DEFAULT', 'index.php');

define('FILENAME_DEFINE_LANGUAGE', 'define_language.php');

define('FILENAME_FILE_MANAGER', 'file_manager.php');

define('FILENAME_GEO_ZONES', 'geo_zones.php');

define('FILENAME_LANGUAGES', 'languages.php');

define('FILENAME_MAIL', 'mail.php');

define('FILENAME_MANUFACTURERS', 'manufacturers.php');

define('FILENAME_MODULES', 'modules.php');

define('FILENAME_NEWSLETTERS', 'newsletters.php');

define('FILENAME_ORDERS', 'orders.php');

define('FILENAME_ORDERS_INVOICE', 'invoice.php');

define('FILENAME_ORDERS_PACKINGSLIP', 'packingslip.php');

define('FILENAME_ORDERS_STATUS', 'orders_status.php');

define('FILENAME_POPUP_IMAGE', 'popup_image.php');

define('FILENAME_PRODUCTS_ATTRIBUTES', 'products_attributes.php');

define('FILENAME_PRODUCTS_EXPECTED', 'products_expected.php');

define('FILENAME_REVIEWS', 'reviews.php');

define('FILENAME_SERVER_INFO', 'server_info.php');

define('FILENAME_SHIPPING_MODULES', 'shipping_modules.php');

define('FILENAME_SPECIALS', 'specials.php');

define('FILENAME_STATS_CUSTOMERS', 'stats_customers.php');

define('FILENAME_STATS_PRODUCTS_PURCHASED', 'stats_products_purchased.php');

define('FILENAME_STATS_PRODUCTS_VIEWED', 'stats_products_viewed.php');

define('FILENAME_TAX_CLASSES', 'tax_classes.php');

define('FILENAME_TAX_RATES', 'tax_rates.php');

define('FILENAME_WHOS_ONLINE', 'whos_online.php');

define('FILENAME_ZONES', 'zones.php');

 

//kgt - discount coupons

define('FILENAME_DISCOUNT_COUPONS','coupons.php');

//end kgt - discount coupons

?>

 

 

Thanks

Share this post


Link to post
Share on other sites

OK, hopefully you read this before you reply to the post above...as I was tinkering I realized I had spaces after the ?> ending, and it does not like this. I corrected them, as a few more popped up and I currently have no warrning.

 

Thank you very, very much and will see how it all works now. And if no one has told you today...you are awesome!

Share this post


Link to post
Share on other sites

Hello. I too have installed the contribution.

 

When I go to /admin/coupons.php I get this error

 

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-9, 9' at line 1

 

select * from discount_coupons cd order by cd.date_end, date_start limit -9, 9

 

[TEP STOP]

 

Any ideas? I've not modified the file, just uploaded it.


Andrew

Share this post


Link to post
Share on other sites
Hi.

Congratulations to this great contibution. :D

 

I have a small question...

can we have amount and not % for a coupon?

 

Like if I want to give 5$ to one of my costumer?

 

Thanks!

 

 

Is someone can help me? please :thumbsup:

Share this post


Link to post
Share on other sites
Hi.

Congratulations to this great contibution. biggrin.gif

 

I have a small question...

can we have amount and not % for a coupon?

 

Like if I want to give 5$ to one of my costumer?

 

Thanks!

Is someone can help me? please :thumbsup:

 

This exact question has been answered in this exact thread. If you would like static discount amounts, you may use CCGV, or develop this one to use them yourself, or wait for me or someone else to get around to working out the crazy logic required to make static discounts work correctly.


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites

Hi, I've just installed 'coupon codes v1.4' and also the coupon.php update. It all seems fine, I turned on the discount coupon module in my catalog admin, created a new coupon, and tried use the coupon in my checkout. Entered the code into the coupon code field and when I reach the checkout_confirmation.php page, there was no discount displaying at all. There were no errors to indicate what went wrong.

 

The code that I entered should be correct as I tried to enter a wrong coupon code and an error saying that the coupon code is not valid appears.

 

Please help.

Share this post


Link to post
Share on other sites
I figured it out...thx for a great contrib!

 

CodeGen please!

 

i have the same problem and no matter how i tried...can't seem to get it fix!

 

spend hoursssss on this forums..!

 

PLEASE HELP ANY ONE!

 

error: at checkout_payment.php

 

"The coupon code you have entered is not valid."

 

 

cheers

Share this post


Link to post
Share on other sites
Hi, I've just installed 'coupon codes v1.4' and also the coupon.php update. It all seems fine, I turned on the discount coupon module in my catalog admin, created a new coupon, and tried use the coupon in my checkout. Entered the code into the coupon code field and when I reach the checkout_confirmation.php page, there was no discount displaying at all. There were no errors to indicate what went wrong.

 

The code that I entered should be correct as I tried to enter a wrong coupon code and an error saying that the coupon code is not valid appears.

 

 

Make sure the module has a unique sort order.

 

Check if you have any other contributions installed that affect the way OSC handles the checkout process (for example, fast easy checkout).


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites

Just installed it.. Since I have enough coding skills to be dangerous, I planned to be dong this ALL NIGHT, but it only turned into about 45mins of coding. Had a few minor errors on MY end, b/c I had to do it manually, I have so many tweaks, I could never replicate my site now!

 

THANKS! I needed something simple for giving July 4th specials and "friends and Family" codes as well!

 

10% off tomorrow at GraysonHobby.com Use coupon code KGT :)

Edited by graysonhobby

Share this post


Link to post
Share on other sites
CodeGen please!

 

i have the same problem and no matter how i tried...can't seem to get it fix!

 

spend hoursssss on this forums..!

 

PLEASE HELP ANY ONE!

 

error: at checkout_payment.php

 

"The coupon code you have entered is not valid."

cheers

 

For starters, Check your dates on the coupon and try to redo the checkout_payment.php file.

Share this post


Link to post
Share on other sites

Hi KGT,

 

I would like the same of Nathalie and I saw your answer too.

 

So, I thinked if is possible to put another field, with Max Order. If is possible, we can to put a limit like: Min order = U$ 24,99 and Max order = U$ 25,00. So, if I set 20% I'll give $ 5 for a products that I bought for $ 25, for example.

 

Is it a solution? (Sorry if I told any or much crap)

 

Thanks

 

Renato

Edited by rdbello

Share this post


Link to post
Share on other sites
I would like the same of Nathalie and I saw your answer too.

 

So, I thinked if is possible to put another field, with Max Order. If is possible, we can to put a limit like: Min order = U$ 24,99 and Max order = U$ 25,00. So, if I set 20% I'll give $ 5 for a products that I bought for $ 25, for example.

 

Is it a solution? (Sorry if I told any or much crap)

 

This is probably the best idea yet. I really don't like the idea of bogging down the code as much as it would take to get the static discount working. At that point, it starts to become as complicated as CCGV, which is entirely opposite the point of this contribution. ;)

 

I suppose in this scenario, Max Order is more "Max Amount to apply discount to" rather than an upper limit on the order amount. The code in the admin section can be even be changed to calculate the correct percentage when supplied with a static discount.

 

Thanks fo the great idea! I will get started and let you know.


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites

Hi,

 

Thanks for your very nice contribution.

 

I have it installed and everything is working flawlessly.

 

I just realized that the coupon % is rounding the amount. Where can I change this in order to keep the exact decimal?

 

 

Many thanks,

-therriee.

Share this post


Link to post
Share on other sites
Hi,

 

Thanks for your very nice contribution.

 

I have it installed and everything is working flawlessly.

 

I just realized that the coupon % is rounding the amount. Where can I change this in order to keep the exact decimal?

Many thanks,

-therriee.

 

Ok, Nevermind, I got it fixed.

 

I didn't check the "set as default" in the currencies module. I thought it was related to this contribution, my mistake.

 

-therriee.

Share this post


Link to post
Share on other sites

OPTION not showing up in admin so can't create coupons. I uploaded all the files and ran the SQL. The box to enter coupon code in checkout is there ok but nothing happens even if I add a non-existing code.

 

Any ideas?

 

http://www.americanpaintballs.com

 

Thanks.

 

Paul


I'm Paul. We developer in Miami Florida since 1995. Not a PHP programmer...I just muddle through with moderate success !

Share this post


Link to post
Share on other sites
OPTION not showing up in admin so can't create coupons. I uploaded all the files and ran the SQL. The box to enter coupon code in checkout is there ok but nothing happens even if I add a non-existing code.

 

You'll need to post your admin/includes/boxes/catalog.php file with the change applied. You've got an error that's causing the problem.


Contributions

 

Discount Coupon Codes

Donations

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

×