Jump to content
kgt

[Contribution] Discount Coupon Codes

Recommended Posts

Ok great, I'll trust that since you have it working and don't seem to have any problems, that I should go ahead and put them on. And that should pretty much fix everything, after two weeks of countless different issues. Muchas gracias! Time to try and promote some more now.

Of course, I spoke too soon. I'm getting one step further each time before I get another error. ha. I'm sure this is another SQL type problem that will be fixed in a similar way, I'm just not sure how. I can type all the stuff to create a coupon, but then when I click Insert, I get a page with the following:

 

1136 - Column count doesn't match value count at row 1

 

insert into discount_coupons values ( 'myspace', 'MySpace Friend 20% off', '.20', 'percent', null, "2008-06-08", 0, 0, null, 100)

 

[TEP STOP]

Share this post


Link to post
Share on other sites
Of course, I spoke too soon. I'm getting one step further each time before I get another error. ha. I'm sure this is another SQL type problem that will be fixed in a similar way, I'm just not sure how. I can type all the stuff to create a coupon, but then when I click Insert, I get a page with the following:

 

1136 - Column count doesn't match value count at row 1

 

insert into discount_coupons values ( 'myspace', 'MySpace Friend 20% off', '.20', 'percent', null, "2008-06-08", 0, 0, null, 100)

 

[TEP STOP]

 

I'm still looking for help on this one. I thought maybe I should run the SQL statements from the README file for the discount coupons, but now when I try to do that (I'm not showing all the columns I don't think when I click discount_coupons in phpmyadmin) I get the error message

 

#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 'CREATE TABLE IF NOT EXISTS discount_coupons ( coupons_id VARCHAR ( 32 ) NOT NUL' at line 1

 

 

I believe I'm supposed to have 10 columns or something, but I only have coupons_id, coupons_description, coupons_discount_percent, coupons_date_start, coupons_date_end, coupons_max_use, coupons_min_order. Anybody? I feel like I'm right there, but I'm just not sure what's going wrong, or more importantly of course, how I fix it. Is there any other information I need to give in order for someone to be able to help me out??

Share this post


Link to post
Share on other sites

I'm using the order total discount code 2.1 with all the bug fixes. I know, I'm using old code but I've tried upgrading & my old version of osCommerce doesn't like it. When I set up a fixed discount, the order total isn't being calculated correctly if I have multiple items in my cart. For example, with $89.90 worth of merch. in my cart totaling 5 items, I use an $80 fixed discount code and only $78.28 is taken off. With 1 $82 item in my cart, it works fine. Any ideas?

Share this post


Link to post
Share on other sites

You should have:

coupons_id

coupons_description

coupons_discount_amount

coupons_discount_type

coupons_date_start

coupons_date_end

coupons_max_use

coupons_min_order

coupons_min_order_type

coupons_number_available

 

Using the SQL below you should be able to remove your existing table (which will remove any coupons already created) and create the table with the appropriate columns:

 

drop table if exists discount_coupons;

create table discount_coupons (

coupons_id varchar(32) not null ,

coupons_description varchar(64) not null ,

coupons_discount_amount decimal(15,12) default '0.000000000000' not null ,

coupons_discount_type enum('fixed','percent','shipping') default 'percent' not null ,

coupons_date_start datetime ,

coupons_date_end datetime ,

coupons_max_use int(3) default '0' not null ,

coupons_min_order decimal(15,4) default '0.0000' not null ,

coupons_min_order_type enum('price','quantity') default 'price' ,

coupons_number_available int(3) default '0' not null ,

PRIMARY KEY (coupons_id)

);

 

 

I believe I'm supposed to have 10 columns or something, but I only have coupons_id, coupons_description, coupons_discount_percent, coupons_date_start, coupons_date_end, coupons_max_use, coupons_min_order. Anybody? I feel like I'm right there, but I'm just not sure what's going wrong, or more importantly of course, how I fix it. Is there any other information I need to give in order for someone to be able to help me out??

~Tracy
 

Share this post


Link to post
Share on other sites
the same thing happend to me.. i'm using RC2a with 3.31 version of DCC...

 

any help pls?

 

I am also having problems with my discount coupons. My coupons are applied to everything. Regardless of exclusions status or min price/qty. I would greatly appreciate any help. I have been searching through these forums for weeks trying to figure it out.

 

Thanks,

Warpz

Share this post


Link to post
Share on other sites

Thanks again for the help. I seem to have it working now...most of the time. haha. I'm getting an error sometimes where an order can be started and then if you go back in to pay and stuff, the code is already in there, and when you try to submit it, the following message comes up, and there's no way to pay.

 

 

1062 - Duplicate entry 'myspace-17' for key 1

 

insert into discount_coupons_to_orders (coupons_id, orders_id) values ('myspace', '17')

 

I have no idea what the "17" is.

 

I did a search through this thread and found someone that appeared to have the same problem, but I'm not quite sure what the solution was, so I hoped maybe you wonderful people could explain it to me. Here's a link to the previous page in the thread where someone had the same sort of issue, in the last few posts.

 

http://forums.oscommerce.com/index.php?sho...p;#entry1065450

 

 

We're getting one step further every time. :)

Share this post


Link to post
Share on other sites
I am also having problems with my discount coupons. My coupons are applied to everything. Regardless of exclusions status or min price/qty. I would greatly appreciate any help. I have been searching through these forums for weeks trying to figure it out.

 

Thanks,

Warpz

 

Some more information...

 

 

Here is an example transaction:

1 x 10ft USB Cable (A-B) - $6.00

disount coupon applied: -$100.00
sub-Total: $-94.00
Shipping Rate: $5.99
Total: $-88.01

 

Here is a debug output (from transaction above):

 

<!-- Discount Coupons DEBUG
order Object
(
[info] => Array
	(
		[order_status] => 1
		[currency] => USD
		[currency_value] => 1.00000000
		[payment_method] => PayPal Direct Payment
		[cc_type] => 
		[cc_owner] => 
		[cc_number] => 
		[cc_expires] => 
		[shipping_method] => Individual Shipping - Zone 1 (Shipping Rate)
		[shipping_cost] => 5.99
		[subtotal] => -94
		[tax] => 0
		[tax_groups] => Array
			(
				[Unknown tax rate] => -0
			)

		[comments] => 
		[total] => -88.01
	)

[totals] => Array
	(
	)

[products] => Array
	(
		[0] => Array
			(
				[qty] => 1
				[name] => 10ft USB Cable (A-B)
				[model] => 
				[tax] => 0
				[tax_description] => Unknown tax rate
				[price] => 6.0000
				[final_price] => 6
				[weight] => 4.00
				[id] => 142
			)

	)

[customer] => Array
	(
		[firstname] => xx
		[lastname] => xx
		[company] => 
		[street_address] => xx
		[suburb] => 
		[city] => xx
		[postcode] => xx
		[state] => xx
		[zone_id] => xx
		[country] => Array
			(
				[id] => 223
				[title] => United States
				[iso_code_2] => US
				[iso_code_3] => USA
			)

		[format_id] => 2
		[telephone] => xx
		[email_address] => xx
	)

[delivery] => Array
	(
		[firstname] => xx
		[lastname] => xx
		[company] => 
		[street_address] => xx
		[suburb] => 
		[city] => xx
		[postcode] => xx
		[state] => xx
		[zone_id] => xx
		[country] => Array
			(
				[id] => 223
				[title] => United States
				[iso_code_2] => US
				[iso_code_3] => USA
			)

		[country_id] => 223
		[format_id] => 2
	)

[content_type] => physical
[billing] => Array
	(
		[firstname] => xx
		[lastname] => xx
		[company] => 
		[street_address] => xx
		[suburb] => 
		[city] => xx
		[postcode] => xx
		[state] => xx
		[zone_id] => xx
		[country] => Array
			(
				[id] => 223
				[title] => United States
				[iso_code_2] => US
				[iso_code_3] => USA
			)

		[country_id] => 223
		[format_id] => 2
	)

[coupon] => discount_coupon Object
	(
		[messages] => Array
			(
				[debug] => Array
					(
						[0] => INFO: DISPLAY_PRICE_WITH_TAX = false
						[1] => INFO: MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING = false
						[2] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_STATUS = true
						[3] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_SORT_ORDER = 1
						[4] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_TYPE = true
						[5] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL = true
						[6] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_TAX = None
						[7] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_EXCLUDE_SPECIALS = true
						[8] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_RANDOM_CODE_LENGTH = 6
						[9] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_LINES = false
						[10] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_ALLOW_NEGATIVE = false
						[11] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_USE_LANGUAGE_FILE = false
						[12] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_CONFIG = Discount Coupon [code] applied
						[13] => INFO: MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG = true
						[14] => INFO: Percentage of discount applied to product 142:  16.666666666667.
						[15] => INFO: Fixed discount applied to product 142:  -10.666666666667.
						[16] => INFO: Fixed adjustment for product 142: difference: 110.66666666667 unadjusted applied_discount: -10.666666666667
						[17] => INFO: Product 142 passed exclusion check.  Discount 100 applied. (fixed)
						[18] => INFO: Discount of 100 applied to product 142 ($6).
						[19] => INFO: Calculating tax on -94.  Displayed price -94.
					)

			)

		[coupon] => Array
			(
				[coupons_id] => dad
				[coupons_description] => fathers day
				[coupons_discount_amount] => 100.000000000000
				[coupons_discount_type] => fixed
				[coupons_date_start] => 2008-05-01 00:00:00
				[coupons_date_end] => 2008-06-16 00:00:00
				[coupons_max_use] => 1
				[coupons_min_order] => 100.0000
				[coupons_min_order_type] => price
				[coupons_number_available] => 100
			)

		[applied_discount] => Array
			(
				[Unknown tax rate] => 100
			)

		[cart_info] => Array
			(
				[valid_products] => Array
					(
						[count] => 1
						[line_items] => 1
						[total] => 6
					)

				[total_products] => Array
					(
						[count] => 1
						[line_items] => 1
						[total] => 6
					)

				[exclusions] => Array
					(
						[categories] => Array
							(
							)

						[products] => Array
							(
							)

						[manufacturers] => Array
							(
							)

					)

			)

		[discount_tax] => Array
			(
				[Unknown tax rate] => 0
			)

	)

)

End Discount Coupons DEBUG-->

Share this post


Link to post
Share on other sites

I just installed the discount coupon codes 3.31 and now my PWA contribution isn't working. It doesn't carry the shipping address and amount over to the checkout_shipping.php. It also will not leave the checkout_shipping.php page to go to the checkout_payment.php page. Exactly what codes do I need to insert to get the PWA working again? Can someone please help me out?

Share this post


Link to post
Share on other sites
I just installed the discount coupon codes 3.31 and now my PWA contribution isn't working. It doesn't carry the shipping address and amount over to the checkout_shipping.php. It also will not leave the checkout_shipping.php page to go to the checkout_payment.php page. Exactly what codes do I need to insert to get the PWA working again? Can someone please help me out?

 

 

 

I've figured out which page it is that's causing the problem but have no idea how to fix it. It's the catalog/includes/classes/order.php. Can someone please help me out? Here is the discount coupon scripts on that page:

 

 

 

 

//kgt - discount coupons

global $coupon;

if( tep_session_is_registered( 'coupon' ) && tep_not_null( $coupon ) ) {

require_once( DIR_WS_CLASSES.'discount_coupon.php' );

$this->coupon = new discount_coupon( $coupon, $this->delivery );

$this->coupon->total_valid_products( $products );

$valid_products_count = 0;

}

//end kgt - discount coupons

 

 

 

 

 

//kgt - discount coupons

if( is_object( $this->coupon ) ) {

$applied_discount = 0;

$discount = $this->coupon->calculate_discount( $this->products[$index], $valid_products_count );

if( $discount['applied_discount'] > 0 ) $valid_products_count++;

$shown_price = $this->coupon->calculate_shown_price( $discount, $this->products[$index] );

$this->info['subtotal'] += $shown_price['shown_price'];

$shown_price = $shown_price['actual_shown_price'];

} else {

$shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];

$this->info['subtotal'] += $shown_price;

}

/**************

$shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];

$this->info['subtotal'] += $shown_price;

**************/

//end kgt - discount coupons

 

 

 

//kgt - discount coupon

if( is_object( $this->coupon ) ) {

$this->info['total'] = $this->coupon->finalize_discount( $this->info );

}

//end kgt - discount coupon

Share this post


Link to post
Share on other sites
I've figured out which page it is that's causing the problem but have no idea how to fix it. It's the catalog/includes/classes/order.php. Can someone please help me out? Here is the discount coupon scripts on that page:

 

 

 

 

//kgt - discount coupons

global $coupon;

if( tep_session_is_registered( 'coupon' ) && tep_not_null( $coupon ) ) {

require_once( DIR_WS_CLASSES.'discount_coupon.php' );

$this->coupon = new discount_coupon( $coupon, $this->delivery );

$this->coupon->total_valid_products( $products );

$valid_products_count = 0;

}

//end kgt - discount coupons

 

 

 

 

 

//kgt - discount coupons

if( is_object( $this->coupon ) ) {

$applied_discount = 0;

$discount = $this->coupon->calculate_discount( $this->products[$index], $valid_products_count );

if( $discount['applied_discount'] > 0 ) $valid_products_count++;

$shown_price = $this->coupon->calculate_shown_price( $discount, $this->products[$index] );

$this->info['subtotal'] += $shown_price['shown_price'];

$shown_price = $shown_price['actual_shown_price'];

} else {

$shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];

$this->info['subtotal'] += $shown_price;

}

/**************

$shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];

$this->info['subtotal'] += $shown_price;

**************/

//end kgt - discount coupons

 

 

 

//kgt - discount coupon

if( is_object( $this->coupon ) ) {

$this->info['total'] = $this->coupon->finalize_discount( $this->info );

}

//end kgt - discount coupon

 

 

 

 

 

 

I solved my problem. The files I was using to install the discount coupon codes contribution in didn't have the PWA contribution in them.

Share this post


Link to post
Share on other sites

Hi, I installed and double checked everything, but still get this error when I go into admin>Discount Coupons:

 

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 '-6, 6' at line 1

 

select * from discount_coupons cd order by cd.coupons_date_end, coupons_date_start limit -6, 6

 

I also get this 1064 error in things like Reviews, Products Expected...The interesting thing with those is that I can easily get rid of the error by simply creating a review or by adding an item for a later date in the case of products expected. The problem with this is that the only way to create a coupon is with the module working, or can I create a coupon manually through the db??? Or is there a way to just get rid of this error??

I've tried the different sql requests mentioned in various posts and in the readme but am getting nowhere...

Thanks

Share this post


Link to post
Share on other sites

Hi,

 

I didn't want to do this but..............

Coupons are installed, all looks ok on the admin side, i can create coupons etc,

but when i go to check out, there is nowhere on the checkout pages to redeem the coupon code?

i've double checked the code on the 2 pages i thought may be to blame but they look ok?

 

Can anyone tell me where i am going wrong?

 

Thanks

Share this post


Link to post
Share on other sites

The box to enter the discount code is on the checkout_payment.php page I believe. I would double check that file, and make sure you are uploading it in ASCII format (not Binary as that can corrupt php script).

 

If you still have no box to enter the code into - paste your checkout_payment.php file here so we can look at it ;)

 

 

 

Hi,

 

I didn't want to do this but..............

Coupons are installed, all looks ok on the admin side, i can create coupons etc,

but when i go to check out, there is nowhere on the checkout pages to redeem the coupon code?

i've double checked the code on the 2 pages i thought may be to blame but they look ok?

 

Can anyone tell me where i am going wrong?

 

Thanks


~Tracy
 

Share this post


Link to post
Share on other sites

I get this error

 

1136 - Column count doesn't match value count at row 1

 

insert into discount_coupons values ( 'YCDBZ0', '', '10', 'fixed', null, null, 0, 0, null, 0)

 

[TEP STOP]

 

when trying to add a new coupon

Share this post


Link to post
Share on other sites
Of course, I spoke too soon. I'm getting one step further each time before I get another error. ha. I'm sure this is another SQL type problem that will be fixed in a similar way, I'm just not sure how. I can type all the stuff to create a coupon, but then when I click Insert, I get a page with the following:

 

1136 - Column count doesn't match value count at row 1

 

insert into discount_coupons values ( 'myspace', 'MySpace Friend 20% off', '.20', 'percent', null, "2008-06-08", 0, 0, null, 100)

 

[TEP STOP]

 

Did you find a fix for this i'm having the same problem.

Share this post


Link to post
Share on other sites
Did you find a fix for this i'm having the same problem.

 

I think coupons_discount_amount is missing from the sql table but I dont know how to fix it

Edited by Windows

Share this post


Link to post
Share on other sites
I think coupons_discount_amount is missing from the sql table but I dont know how to fix it

 

I found the fix for this in another thread thanks to TracyS

 

Using the SQL below you should be able to remove your existing table (which will remove any coupons already created) and create the table with the appropriate columns:

 

drop table if exists discount_coupons;

create table discount_coupons (

coupons_id varchar(32) not null ,

coupons_description varchar(64) not null ,

coupons_discount_amount decimal(15,12) default '0.000000000000' not null ,

coupons_discount_type enum('fixed','percent','shipping') default 'percent' not null ,

coupons_date_start datetime ,

coupons_date_end datetime ,

coupons_max_use int(3) default '0' not null ,

coupons_min_order decimal(15,4) default '0.0000' not null ,

coupons_min_order_type enum('price','quantity') default 'price' ,

coupons_number_available int(3) default '0' not null ,

PRIMARY KEY (coupons_id)

);

Share this post


Link to post
Share on other sites

just an update on my previous post should some1 run into the same sql problem (1064) that I was having. The answer, as I thought, was to go into phpmyadmin, under the table "discount_coupons", and manually "insert" a coupon by filling in the fields under that tab. This took away the sql error and allowed me to finish the installation of the program. Again this might just be an oddity in my whole custom template, but worth a try if you're getting the same thing.

 

My next question: Is there a way for the coupon to be featured in the cost breakdown on the "order confirmation" page. Mine only shows the total products in one box at full price, and then the discounted price is reflected in the subtotal, which is fine, but some customers that are mathematically challenged may not believe they're getting the discount if they don't see a line that says "coupon -$XXX" ...you follow me?

 

Does anyone have a full final packet for download of this contribution?

 

thanks

http://addons.oscommerce.com/info/4269

I believe your looking for discount coupon codes 3.31 (about 8 down). Install the fixes after if you should run into any of those issues..I haven't, although the fix that keeps the shipping in the event of a negative total price, seems worthy.

 

 

 

Hi,

 

I didn't want to do this but..............

Coupons are installed, all looks ok on the admin side, i can create coupons etc,

but when i go to check out, there is nowhere on the checkout pages to redeem the coupon code?

i've double checked the code on the 2 pages i thought may be to blame but they look ok?

 

Can anyone tell me where i am going wrong?

 

Thanks

I don't mean to ask you an obvious question, but did you actually finish the install under admin>modules>order totals>discount coupons..."install"? I ask because I forgot that step too, and was looking around for a while, lol :blush: . They do mention it in the readme, so I assume some others missed it too.

EDIT...I already had a coupon installed as a fix to the sql problem I mentioned above which is why i thought i was done, re-reading your post you probably did this already...sorry.

Edited by coolfly

Share this post


Link to post
Share on other sites

Hi, I've scanned this thread trying to find an answer to the problem we're having and haven't had any luck.

 

We installed this module roughly 6 months ago for a client. She just created a discount that's supposed to take 10% off of an entire order. It works as intended if a customer doesn't buy multiple quantities of the same product. However, if a customer tries to purchase 2 or more of the same product, the 10% is taken off multiple times. For example:

 

4 x Product A : $139.96

Discount Coupon : - 14.00 //displaying correct amount

Sub-Total : 83.98 //incorrect sub-total

 

What appears to be happening is the quantity is multiplying the discount and then subtracting from the total, like this:

4 quantity * 10% = 40%

139.96 - 40% = 83.98

 

Has anyone else experienced this error? If so, could you please point me in the right direction as to how to fix it? Thanks so much for your help.

-Josh

Share this post


Link to post
Share on other sites
Hi, I have a question on moving the input box of coupon code from checkout_payment.php to checkout_shipping.php. The reason is I have PayPal Express Checkout and it will skip checkout_payment.php and go straight to the order_confirmation.php.

 

I have tried moving the coupon input box code to checkout_shipping.php but when I input a discount code in there it's not picking up at all. It seems the input box only works on the checkout_payment.php page.

 

May I know is there a way to move the input coupon code box from checkout_payment.php to checkout_shipping.php? Are there any files that I need to edit as well?

 

Thanks a lot!

 

 

 

I have PayPal Express also and I'm having the same problem. How do you get it to work with the discount code contribution?

Share this post


Link to post
Share on other sites

I'm still wondering if there's any possibility at all that anyone would know a fix for the problem I mentioned previously....

 

 

I'm getting an error sometimes where an order can be started and then if you go back in to pay and stuff (like if you have an item saved in your shopping cart and came back a day later to buy it), the code is already in there, and when you try to submit it, the following message comes up, and there's no way to pay.

 

 

1062 - Duplicate entry 'myspace-17' for key 1

 

insert into discount_coupons_to_orders (coupons_id, orders_id) values ('myspace', '17')

Share this post


Link to post
Share on other sites

Hello,

 

I use this contribution for a long time with succes.

But after mine provider had upgraded to php5 is there something wrong.

 

When you put in a discount code it is not visible on the checkout_payment page.

The discount is also not applied.

When you press F5 it's there and applied as well.

 

I still haven't find the solution on the dutch and english forum, so is there anybody who's knows this problem?

 

regards,

Jan


Dreams can come true, if you help them a littlebit

Share this post


Link to post
Share on other sites

Thank you i installed that contribution and it seemed to work find but when i click on "Confirm Order" i get blank page with this error: "(270) Line item 1 is invalid"

 

Does anyone know what the means?

 

Thank you very much

Share this post


Link to post
Share on other sites
Try adding this code:

 

if (!tep_session_is_registered('coupon')) tep_session_register('coupon');
 if (tep_not_null($HTTP_POST_VARS['coupon'])) {
$coupon = tep_db_prepare_input($HTTP_POST_VARS['coupon']);
 }

 

 

BEFORE these lines:

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

 

Hello, after the upgrade(php/globals off) by the provider i have the same problem.

Only there is no calculation and the discount is not showed on checkout_confirmation. After a refresh it's OK.

The solution mentioned above is not working for me.

I am searching for a week now and still no solution. I'm open for everything.

Somebody an idea?

 

Thanks.

 

regards,

Jan


Dreams can come true, if you help them a littlebit

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

×