Latest News: (loading..)
kgt

[Contribution] Discount Coupon Codes

3,505 posts in this topic

Hi

This contribution is what i really need ;) but ...

 

I have manually installed the last version ... everything works fine until the last validation

( I can create a discount coupon, i can valid the cart, the price is exact with the discount, etc ... )

then i get this error message :

 

" 1146 - Table 'db157787952.TABLE_DISCOUNT_COUPONS_USE_COUNT' doesn't exist

 

insert into TABLE_DISCOUNT_COUPONS_USE_COUNT (coupons_id, orders_id) values ('reduc5', '32')

 

[TEP STOP] "

 

It's the same even with the max use = 0 or 1

 

Of course the Table doesn't not exist ... and i can't find where i did this mistake ... i can't see either in the install.txt something about this table ...

 

Thanks for the help ;)

 

Phil

 

Lines 116-122 of checkout_process.php should be:

 

//kgt - discount coupons
 if( tep_session_is_registered( 'coupon' ) && $order->info['coupon'] != '' ) {
  $sql_data_array = array( 'coupons_id' => $order->info['coupon'],
												   'orders_id' => $insert_id );
  tep_db_perform( TABLE_DISCOUNT_COUPONS_TO_ORDERS, $sql_data_array );
 }
 //end kgt - discount coupons

 

Replace the code you have with this.

Share this post


Link to post
Share on other sites
Okay. I copied the list you sent me and I overwrote the bad list. MAGIC! Suddenly, I feel a little better, like I might not be brain dead after all. But, all I fixed was the presentation in the middle section of the graphics - which are still at the dead bottom of the page, after the still present column of code. And the side bar graphics and all of the titles are still bad - Header_Title_Top>>Header etc. Box_Heading_Whats_New Stuff like that. So I haven't solved the bulk of the problem.

 

Any other wisdom?

 

Problem Solved: we are on a remote computer, editing code on a server, several pages at a time. Evidently, our cat/includes/lang/eng.php file had become corrupted, or inadvertently edited, and the code had been truncated. We went back to the server, generated a fresh store, copied the code from that fresh source, closed the source and pasted the code into the real store file. Everything is working now. I just want to record this in case there are other store owners out there who are as green as php as we are and might have gotten themselves into the same kind of fix.

 

Like I said, the symptoms are these: you go to a page, and it has a huge glob of code there instead of the lovely thing you expected to see.http://forums.oscommerce.com/style_images/1/folder_post_icons/icon8.gif

 

My deep appreciation for the help.http://forums.oscommerce.com/style_images/1/folder_post_icons/icon12.gif

Share this post


Link to post
Share on other sites
Okay. I copied the list you sent me and I overwrote the bad list. MAGIC! Suddenly, I feel a little better, like I might not be brain dead after all. But, all I fixed was the presentation in the middle section of the graphics - which are still at the dead bottom of the page, after the still present column of code. And the side bar graphics and all of the titles are still bad - Header_Title_Top>>Header etc. Box_Heading_Whats_New Stuff like that. So I haven't solved the bulk of the problem.

 

Any other wisdom?

 

Problem Solved: we are on a remote computer, editing code on a server, several pages at a time. Evidently, our cat/includes/lang/eng.php file had become corrupted, or inadvertently edited, and the code had been truncated. We went back to the server, generated a fresh store, copied the code from that fresh source, closed the source and pasted the code into the real store file. Everything is working now. I just want to record this in case there are other store owners out there who are as green as php as we are and might have gotten themselves into the same kind of fix.

 

Like I said, the symptoms are these: you go to a page, and it has a huge glob of code there instead of the lovely thing you expected to see.http://forums.oscommerce.com/style_images/1/folder_post_icons/icon8.gif

 

My deep appreciation for the help.http://forums.oscommerce.com/style_images/1/folder_post_icons/icon12.gif

Share this post


Link to post
Share on other sites
You're not going to see the order total line for the discount coupon in Paypal. Paypal displays the subtotal, the shipping, and the total. You should make sure you have "Display Subtotal with Applied Discount" set to true in Modules > Order Total > Discount Coupons. Verify that your subtotal displayed by Paypal is the item total - discount + taxes, and the total is the subtotal + shipping.

 

I am transferring the shoppingcart to PayPal instead of an aggregate. Maybe that's why the total in PayPal doesn't correspond with the total that Discount Coupon Codes displays in the shop? I have set Display Subtotal with Applied Discount" to true.

 

Any idea ?

Share this post


Link to post
Share on other sites
Lines 116-122 of checkout_process.php should be:

 

//kgt - discount coupons
 if( tep_session_is_registered( 'coupon' ) && $order->info['coupon'] != '' ) {
  $sql_data_array = array( 'coupons_id' => $order->info['coupon'],
												   'orders_id' => $insert_id );
  tep_db_perform( TABLE_DISCOUNT_COUPONS_TO_ORDERS, $sql_data_array );
 }
 //end kgt - discount coupons

 

Replace the code you have with this.

 

FANTASTIC !!! :D

 

Thanks a lot !! Everything is perfect now !!!

Share this post


Link to post
Share on other sites
Okay. I copied the list you sent me and I overwrote the bad list. MAGIC! Suddenly, I feel a little better, like I might not be brain dead after all. But, all I fixed was the presentation in the middle section of the graphics - which are still at the dead bottom of the page, after the still present column of code. And the side bar graphics and all of the titles are still bad - Header_Title_Top>>Header etc. Box_Heading_Whats_New Stuff like that. So I haven't solved the bulk of the problem.

 

Any other wisdom?

 

Problem Solved: we are on a remote computer, editing code on a server, several pages at a time. Evidently, our cat/includes/lang/eng.php file had become corrupted, or inadvertently edited, and the code had been truncated. We went back to the server, generated a fresh store, copied the code from that fresh source, closed the source and pasted the code into the real store file. Everything is working now. I just want to record this in case there are other store owners out there who are as green as php as we are and might have gotten themselves into the same kind of fix.

 

Like I said, the symptoms are these: you go to a page, and it has a huge glob of code there instead of the lovely thing you expected to see.http://forums.oscommerce.com/style_images/1/folder_post_icons/icon8.gif

 

My deep appreciation for the help.http://forums.oscommerce.com/style_images/1/folder_post_icons/icon12.gif

Share this post


Link to post
Share on other sites
I am transferring the shoppingcart to PayPal instead of an aggregate. Maybe that's why the total in PayPal doesn't correspond with the total that Discount Coupon Codes displays in the shop? I have set Display Subtotal with Applied Discount" to true.

 

 

Since you're using the itemized function, you're allowing Paypal to recalculate the shopping cart total. Not only will the subtotal be wrong, but so will tax.

 

In order for this to work, you either need to use the Aggregate cart for Paypal, or change the code for your Paypal payment module to send the discounted products prices. This would mean that the confirmation page on your site would look like this:

 

1 x Item 1 $9.99

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

Discount: -$1.00

Subtotal: $8.99

Tax (assume 5%): $0.45

S&H: $5.00

Total: $14.44

 

And this is how it would look in Paypal:

 

1 x Item 1 $8.99

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

Tax: $0.45

S&H: $5.00

Total: $14.44

 

So Paypal would display a different product price in order to trick it into calculating the correct total. If you used the aggregate method, this is how the same cart would look in Paypal:

 

Payment to your site $9.44

S&H: $5.00

Total: $14.44

 

Which would be the correct total.

Share this post


Link to post
Share on other sites
Something like "Available Coupons?" That seems like a quickie. If you're really interested, I can throw that together and let you test it out!

 

 

Hi KGT,

 

I have got the max use working but as said its per customer. Have you had time to look at coding the above? I would also be very interested in testing this for you.

 

This way if I wanted to give something away (stock I longer want) but have say only 8 left I can advertise a coupon and say first 8 orders using this coupon get X product free. Then when its been used 8 times the coupon is invalid.

 

Also with regards to the date issue. I have set either start or end date to 14/06/2006 (14th June 2006) yet when i insert the coupon the date comes out as 02/06/2007 if I input the date as 06/14/2006 all is fine.

 

I believe the below code is what sets the date format please correct if I am mistaken

 

from catalog\includes\languages\english.php

define('DATE_FORMAT_SHORT', '%d/%m/%Y');  // this is used for strftime()
define('DATE_FORMAT_LONG', '%A %d %B, %Y'); // this is used for strftime()
define('DATE_FORMAT', 'd/m/Y'); // this is used for date()
define('DATE_TIME_FORMAT', DATE_FORMAT_SHORT . ' %H:%M:%S');

////
// Return date in raw format
// $date should be in format dd/mm/yyyy
// raw date is in format DDMMYYYY, or DDMMYYYY

 

Regards and keep up the great work :D

Shaun

Edited by Get-Wireless 2

Share this post


Link to post
Share on other sites
I have got the max use working but as said its per customer. Have you had time to look at coding the above? I would also be very interested in testing this for you.

 

This way if I wanted to give something away (stock I longer want) but have say only 8 left I can advertise a coupon and say first 8 orders using this coupon get X product free. Then when its been used 8 times the coupon is invalid.

 

It shouldn't take too long. I won't be able to work on it today or tomorrow morning, but hopefully tomorrow afternoon will work. I'll PM you to test it.

 

Also with regards to the date issue. I have set either start or end date to 14/06/2006 (14th June 2006) yet when i insert the coupon the date comes out as 02/06/2007 if I input the date as 06/14/2006 all is fine.

 

Did you download v. 1.3? It's supposed to handle other date formats. Since it's apparently assuming US format, it's converting 14/06/2006 (an invalid date) to what it thinks you might mean. Since you have 14 and there are only 12 months, it's assuming you mean February of the year after the one you supplied.

 

Do your dates display correctly, or do they display in US format?

Share this post


Link to post
Share on other sites
It shouldn't take too long. I won't be able to work on it today or tomorrow morning, but hopefully tomorrow afternoon will work. I'll PM you to test it.

Did you download v. 1.3? It's supposed to handle other date formats. Since it's apparently assuming US format, it's converting 14/06/2006 (an invalid date) to what it thinks you might mean. Since you have 14 and there are only 12 months, it's assuming you mean February of the year after the one you supplied.

 

Do your dates display correctly, or do they display in US format?

 

I will download version 1.3 and give it a bash just as soon as I have made a cuppa tea :D

Sorry I didnt mean to try and rush into trying the other code thing was just enquiring.

If you could drop me a message when you have had time to have a look a the code I would be more than willing to test it out for you.

 

Great contrib thanks

Shaun

Share this post


Link to post
Share on other sites

hi

 

i am a bit flumoxed

 

all works fine - except for total -

 

Discount Coupon 9 applied: -?38.33

Sub-Total: ?345.03

Total: ?0.00

 

 

my order totals are in the following number order

 

delivery 1

discount coupon 2

subtotal 3

tax 4

total 5

 

am i staring the solution in the face ? :'(

Share this post


Link to post
Share on other sites

Hi,

 

I have juat finnished updating and testing version 1.3

Altered these files

 

Admin\coupons.php

catalog\checkout_confirmation.php

 

Now if I put in UK format date Ie 15\06\2006 or just erases it, how ever US format still seems to work.

 

I am assuming I may need to edit one of my english.php files tho am not sure which one or what to edit. so I am gonna have a nosey around here see if I can find what i need to do.

regards

Shaun

Share this post


Link to post
Share on other sites

I have made an update for people (like me) who have Access with Level Account installed. Simple change.

Share this post


Link to post
Share on other sites
hi

 

i am a bit flumoxed

 

all works fine - except for total -

 

Discount Coupon 9 applied: -?38.33

Sub-Total: ?345.03

Total: ?0.00

my order totals are in the following number order

 

delivery 1

discount coupon 2

subtotal 3

tax 4

total 5

 

am i staring the solution in the face ? :'(

 

ignore this - i replaced last paragraph in orders.php instead of appending it

Share this post


Link to post
Share on other sites

well trying to figure out were I should be latering the date isnt as easy as I thought it would be :(

 

Been searching for ages now without any luck :(

Share this post


Link to post
Share on other sites

thanks for this great contrib, all is working fine

 

apart that i do not get the shipping price printed on the invoice it misses it out

 

+++++++++++++++++++++++++

 

Discount Coupon 123456789 applied: -$3.48

Sub-Total: $66.02

CA TAX 8.25%: $5.45

Total: $81.73

========================

 

anyone got any advice thanks

 

:D RT

Share this post


Link to post
Share on other sites
thanks for this great contrib, all is working fine

 

apart that i do not get the shipping price printed on the invoice it misses it out

 

+++++++++++++++++++++++++

 

Discount Coupon 123456789 applied: -$3.48

Sub-Total: $66.02

CA TAX 8.25%: $5.45

Total: $81.73

========================

 

anyone got any advice thanks

 

:D RT

 

sorry could not edit my post above:

 

=========================

 

when orders are placed without the coupon i get the shipping price printed on the invoice??

Share this post


Link to post
Share on other sites
well trying to figure out were I should be latering the date isnt as easy as I thought it would be :(

 

You'll need to make sure you have the right format in admin/includes/languages/english.php. That's the file that will affect the date format. If the format in that is correct, then I dunno! When you did the upgrade, did you upgrade admin/coupons.php by uploading the included file, or did you follow the instructions to upgrade. If you followed the instructions (and haven't made any changes to admin/coupons.php) then try overwriting it with the included file and see if that fixes it.

Share this post


Link to post
Share on other sites
sorry could not edit my post above:

 

=========================

 

when orders are placed without the coupon i get the shipping price printed on the invoice??

 

What sort order do you have for shipping and for coupons in Modules > Order Total?

Share this post


Link to post
Share on other sites
What sort order do you have for shipping and for coupons in Modules > Order Total?

 

 

they was both reading 0 i have changed them to different numbers and all is working thanks.

 

but my minimum order with coupon is $50 i added 51.99 to my cart and i got the default error message you have to put $50 in your cart for this coupon ???????

 

any way thanks for your response my invoices are all okay

 

Regards

RT

Share this post


Link to post
Share on other sites
but my minimum order with coupon is $50 i added 51.99 to my cart and i got the default error message you have to put $50 in your cart for this coupon ???????

 

I found this can happen if you display the subtotal with the discount applied. If the discount brings your order subtotal below this limit, then you'll still get the message. In checkout_confirmation.php line 90

 

replace

			if( $row['min_order'] != 0 && $row['min_order'] > $order->info['subtotal'] ) { 
			$error_message[] = sprintf( ENTRY_DISCOUNT_COUPON_MIN_ERROR, $currencies->format( $row['min_order'], true, $order->info['currency'], $order->info['currency_value'] ) );
		}

with

			if( $row['min_order'] != 0 ) {
	if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'false' && $row['min_order'] > $order->info['subtotal'] ) {
				$error_message[] = sprintf( ENTRY_DISCOUNT_COUPON_MIN_ERROR, $currencies->format( $row['min_order'], true, $order->info['currency'], $order->info['currency_value'] ) );
			} else if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'true' ) {
	  $subtotal = $order->info['subtotal'];
		  foreach( $order->info['applied_discount'] as $discount ) {
			  $subtotal += $discount;
			}
			if( $row['min_order'] > $subtotal ) {
				$error_message[] = sprintf( ENTRY_DISCOUNT_COUPON_MIN_ERROR, $currencies->format( $row['min_order'], true, $order->info['currency'], $order->info['currency_value'] ) );
				}
			}
		}

 

See if that works for your order.

Share this post


Link to post
Share on other sites

Thanks KGT it seems my language file in admin section had an incorrect entry. I have altered it and it works fantastic :D

 

Well pleased :D

 

Regards

Shaun

Share this post


Link to post
Share on other sites

what the hell!

 

i am VERY SURE that my problem got nothing to do with this contribution BUT after i installed this contrubition...play with it for a few minutes THEN got this error:

 

Warning: mysql_connect(): Lost connection to MySQL server during query in /home/.berthram/voteforaustralia/voteforaustralia.com/catalog/includes/functions/database.php on line 19

Unable to connect to database server!

 

 

urrr! the contrubition make NO changes to the database.php...ANY ONE EXPERICE SAME?

or can help out...

 

both in catalog and admin got same error!

 

meanwhile, i have tried to contact my host to see if the server down

 

cheers!

Share this post


Link to post
Share on other sites
Warning: mysql_connect(): Lost connection to MySQL server during query in /home/.berthram/voteforaustralia/voteforaustralia.com/catalog/includes/functions/database.php on line 19

Unable to connect to database server!

urrr! the contrubition make NO changes to the database.php...ANY ONE EXPERICE SAME?

or can help out...

 

This error is often related to max_allowed_packet, which defines how large a dataset MySQL is allowed to transfer per query. This contribution is unlikely to have been the cause of this, since it shouldn't be returning any large datasets unless there's a serious bug. ;)

 

http://dev.mysql.com/doc/refman/5.0/en/packet-too-large.html

 

This is something your host will have to look into.

Share this post


Link to post
Share on other sites
I found this can happen if you display the subtotal with the discount applied. If the discount brings your order subtotal below this limit, then you'll still get the message. In checkout_confirmation.php line 90

 

 

Is that fixed in the latest version, or should I apply this fix manually.

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