Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Discount Coupon Codes


kgt

Recommended Posts

I'm trying to use this contribution with PayPal WPP. From the limited understanding I have of the programming, I 've added the following code to checkout_shipping.php:

 

/* kgt - discount coupons 1/30/07 -AM*/

if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_STATUS == 'true' ) {

?>

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td class="main"><b><?php echo 'Do you have a Coupon Code?'; ?></b></td>

</tr>

</table></td>

</tr>

<tr>

<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">

<tr class="infoBoxContents">

<td><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td class="main"><?php echo ENTRY_DISCOUNT_COUPON.' '.tep_draw_input_field('coupon', '', 'size="32"'); ?></td>

</tr>

</table></td>

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php

}

/* end kgt - discount coupons */

 

The original method of purchasing (log-in, checkout, etc) works perfectly. But when I go the route of PayPal WPP I cannot seem to get the coupon code working. As far as I know it should simply apply the coupon after it comes back from the PayPal site; is that correct?

 

From what I understand I don't need to add anything extra from a post I found earlier in the support. My apologies if this has long been answered KGT, I'm just looking for some guidance.

 

-Aaron

Link to comment
Share on other sites

I'm trying to use this contribution with PayPal WPP. From the limited understanding I have of the programming, I 've added the following code to checkout_shipping.php:

 

That code should be added to checkout_payment.php. Are you trying to add this to the shipping page instead of the payment page? If so, that is the code that displays the box to allow a customer to input the discount code. The code that handles the discount (processes the discount code and determines the discount amount) needs to be added as well.

 

The original method of purchasing (log-in, checkout, etc) works perfectly. But when I go the route of PayPal WPP I cannot seem to get the coupon code working. As far as I know it should simply apply the coupon after it comes back from the PayPal site; is that correct?

 

Not sure how the Paypal WPP contribution works, exactly. Which exactly did you download and install?

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Hi i have installed this contribution and it all seems to be working except how does the customer enter the discount code and where? It does not seem to be shown, in the admin it all workd and you can add codes etc. Please Help Thanks Josh

 

There should be a link under the Catalog Menu in your admin section. If it is not there, revisit the installation instructions for admin/includes/boxes/catalog.php.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Another option might be Separate Pricing Per Customer which would allow you to setup a Wholesale customer group. When they log in they see their prices rather than retail prices. You can use Discount Coupon Codes as well as Separate Pricing Per Customer too - so there could still be coupons.

 

 

Thank you very much! I will definitely do that

Link to comment
Share on other sites

I am getting the following error when i try to use Discount Coupon, please help me.

 

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

 

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

Link to comment
Share on other sites

I downloaded the PayPal WPP so out customers could check out without signing into the website.

 

WPP takes the customer to a PayPal site, allows them to login or pay with their credit card, and sends them back to checkout_shiping.php for confirmation. I would like to add the discount coupon to that page so they can take advantage of the discount even while paying with Paypal.

 

I also have another question, why does the cart reject the American Express cards? They only have 15 numbers, and the checkout requires 16 digits.

 

-Aaron

TummyToys

 

That code should be added to checkout_payment.php. Are you trying to add this to the shipping page instead of the payment page? If so, that is the code that displays the box to allow a customer to input the discount code. The code that handles the discount (processes the discount code and determines the discount amount) needs to be added as well.

Not sure how the Paypal WPP contribution works, exactly. Which exactly did you download and install?

Link to comment
Share on other sites

Answered my own after some investigation:

 

The minimum CC is in the minimum values section of the admin tool.

 

I also have another question, why does the cart reject the American Express cards? They only have 15 numbers, and the checkout requires 16 digits.

 

-Aaron

TummyToys

Link to comment
Share on other sites

I am getting the following error when i try to use Discount Coupon, please help me.

 

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

 

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

 

Stolen from earlier in the forum:

 

kgt, Everything is working fine locally, BUT, I'm getting a lousy 1064 error in admin on the live site after installing.

 

Discount Coupons NOTICE: Click here to read the Discount Coupon Codes manual for help editing 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 '-12, 12' at line 1

 

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

 

Update for anyone else having this problem.

 

Found the solution here:

 

http://www.oscommerce.com/community/bugs,1605

(look for the post dated april 15 05)

 

This is a bug in oscommerce

admin->includes->classes->split_page_result.php file.

 

Error code :

Approximate Line : 34

Function : splitPageResults

 

LOOK FOR

 

$offset = ($max_rows_per_page * ($current_page_number - 1));

$sql_query .= " limit " . $offset . ", " . $max_rows_per_page;

 

This creates a problem if there is no record in database.

 

Fix ( Replace the above two lines with this code )

 

$offset = 0;

if($current_page_number > 0){

$offset = ($max_rows_per_page * ($current_page_number - 1));

}

$sql_query .= " limit " . $offset . ", " . $max_rows_per_page;

 

 

Seems to be working now.

 

Hope this helps

 

-Aaron

TummyToys

Link to comment
Share on other sites

Hello all. Love the contribution as it is exactly what I needed. I have one issue though. I use another conrtib (Dangling Carrot) to offer free incentives at certain price marks (spend XX and get this free). Discounts work fine when the all items have a price on them but when the free gift is added it takes the $0 amount and tries to divide it. So if I have a $50 item and use the $10 off coupon it subtracts the correct amount but if I have the $50 amount and the $0 (free gift) it only subtracts $5. If there are three items ($20, $30, $0) then the amount deducted is thirded (I think). Is there a way to excluded items worth $0 from the discount?

Link to comment
Share on other sites

I love this contribution. I have done something unique with it, but would like some help with one minor glitch.

 

On my website I offer discounts that increase as your order total increases. The discount structure is:

order qty 2 = 10% discount

order qty 3 = 20% discount

order qty 4 = 30% discount

order qty 5 or more = 40% discount

 

I altered my checkout_confirmation.php file to automatically use the right coupon depending on the order quantity, and set the display format for this contrib so that you can't see the coupon code that you are using. That way the customers can't put 5 items in their cart and go to checkout, then see the coupon code for the 40% discount and use that code for an order with fewer items.

 

The problem I have is this: when a customer gets all the way to the checkout_confirmation page and then goes back to make changes to their cart, the next time they go through the checkout proces the coupon code shows up in the input box on the checkout_payment.php page. Does anyone know how I can keep this from happening? Any suggestions are greatly appreciated.

Link to comment
Share on other sites

I downloaded the PayPal WPP so out customers could check out without signing into the website.

 

WPP takes the customer to a PayPal site, allows them to login or pay with their credit card, and sends them back to checkout_shiping.php for confirmation. I would like to add the discount coupon to that page so they can take advantage of the discount even while paying with Paypal.

 

You will need to move the code from checkout_confirmation.php to checkout_shipping.php. Checkout_shipping posts the form information back to itself (and I assume the contribution you have then forwards the customer to Paypal).

 

You'll need to change error handling in that code to not point to the checkout_payment page, but checkout_shipping instead.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Hello all. Love the contribution as it is exactly what I needed. I have one issue though. I use another conrtib (Dangling Carrot) to offer free incentives at certain price marks (spend XX and get this free). Discounts work fine when the all items have a price on them but when the free gift is added it takes the $0 amount and tries to divide it. So if I have a $50 item and use the $10 off coupon it subtracts the correct amount but if I have the $50 amount and the $0 (free gift) it only subtracts $5. If there are three items ($20, $30, $0) then the amount deducted is thirded (I think). Is there a way to excluded items worth $0 from the discount?

 

 

Comment out line 116 of includes/classes/discount_coupon.php. I think that will fix the problem for you.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Hi All,

 

I got a strange problem, is there anyone can help?

I using this code for the percentage discount coupon without any problem. Today, i try to use the fix price discount function it shows a strange problem:

 

I setup fix price discount code $2.14

When subtotal = $6.95; discount shows 2.14. no problem.

When subtotal = $102.74 discount shows 2.15.

When subtotal = $149.85 discount shows 2.13.

When subtotal = $302.54 discount shows 2.15.

When subtotal = $402.48 discount shows 2.11.

 

The error are repeatable.

Please help.

Thank you very much and have a great day!

Link to comment
Share on other sites

I love this contribution. I have done something unique with it, but would like some help with one minor glitch.

 

On my website I offer discounts that increase as your order total increases. The discount structure is:

order qty 2 = 10% discount

order qty 3 = 20% discount

order qty 4 = 30% discount

order qty 5 or more = 40% discount

 

I altered my checkout_confirmation.php file to automatically use the right coupon depending on the order quantity, and set the display format for this contrib so that you can't see the coupon code that you are using. That way the customers can't put 5 items in their cart and go to checkout, then see the coupon code for the 40% discount and use that code for an order with fewer items.

 

The problem I have is this: when a customer gets all the way to the checkout_confirmation page and then goes back to make changes to their cart, the next time they go through the checkout proces the coupon code shows up in the input box on the checkout_payment.php page. Does anyone know how I can keep this from happening? Any suggestions are greatly appreciated.

 

So you have these auto-magical hidden coupons, but you also need to allow people to enter a coupon manually? Or is it one or the other: they get the auto-magical breakdown OR they can enter a coupon?

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Hi All,

 

I got a strange problem, is there anyone can help?

I using this code for the percentage discount coupon without any problem. Today, i try to use the fix price discount function it shows a strange problem:

 

I setup fix price discount code $2.14

When subtotal = $6.95; discount shows 2.14. no problem.

When subtotal = $102.74 discount shows 2.15.

When subtotal = $149.85 discount shows 2.13.

When subtotal = $302.54 discount shows 2.15.

When subtotal = $402.48 discount shows 2.11.

 

The error are repeatable.

Please help.

Thank you very much and have a great day!

 

Many people see an improvement in accuracy when they comment out line 116 of includes/classes/discount_coupon.php. See if that helps.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

So you have these auto-magical hidden coupons, but you also need to allow people to enter a coupon manually? Or is it one or the other: they get the auto-magical breakdown OR they can enter a coupon?

 

Thank you for your quick reply!

 

The customer enter a coupon.

Link to comment
Share on other sites

Just commented out line 116 of includes/classes/discount_coupon.php. But not works. :-"

 

 

Well I'd need to see more info before I could make another suggestion/fix.

 

I need the price and quantities of items in your cart (the individual items matter, since the discount is NOT applied to the subtotal, but to each individual item).

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Well I'd need to see more info before I could make another suggestion/fix.

 

I need the price and quantities of items in your cart (the individual items matter, since the discount is NOT applied to the subtotal, but to each individual item).

 

 

THANK YOU!!

 

CASE#1

9 x zCover TypeOn APKDA fits Apple Desktop & Wireless Keyboard , Sony Vegas $449.55

1 x zCover care removable lanyard $4.99

 

Discount Coupon $2.14 Discount applied: -$2.15

Sub-Total: $452.39

Shipping Rate: $7.50

Total: $459.89

 

CASE #2

10 x zCover TypeOn APKDA fits Apple Desktop & Wireless Keyboard , Sony Vegas $499.50

1 x zCover care removable lanyard $4.99

Discount Coupon $2.14 Discount applied: -$2.17

Sub-Total: $502.32

Shipping Rate: $7.50

Total: $509.82

 

CASE#3 (no problem one)

1 x zCover TypeOn APKDA fits Apple Desktop & Wireless Keyboard , Sony Vegas $49.95

1 x zCover care removable lanyard $4.99

Discount Coupon $2.14 Discount applied: -$2.14

Sub-Total: $52.80

Shipping Rate: $7.50

 

this Coupon has setup with following setting

Description: $2.14 Discount

Percent Discount:1.00 OR Desired Fixed Discount:2.14

Start Date:

End Date:

Max Use:

Min Order: 2.14

Max Order: 2.14

Number Available:

 

 

Thank you very much for your help :)

Edited by wlshf
Link to comment
Share on other sites

So you have these auto-magical hidden coupons, but you also need to allow people to enter a coupon manually? Or is it one or the other: they get the auto-magical breakdown OR they can enter a coupon?

 

 

It's the either/or scenario. They still have the ability to enter their own coupon code, but if they leave the coupon field blank and their order quantity is >= 2 then a hidden coupon gets applied.

 

I just realized that I can add min and max values to the hidden coupons to keep people from using them when they aren't supposed to, but I would rather they just didn't ever seen the coupon code.

Link to comment
Share on other sites

Comment out line 116 of includes/classes/discount_coupon.php. I think that will fix the problem for you.

 

Ok I commented it out and now when there are three items (one for $99, one for $49 and one for $0) it shows a $10 off coupon as $6.66 (roughly 2/3 of $10). Is there a way to tell it to not calculate products if their cost is less than or equal to 0? Also I keep getting a "can't divide by zero" error so I wrapped lines 113 and 114 in the following if statment and it no longer displays this error:

		if($product['final_price'] != 0) {
		$max_applied_percentage = ( $this->coupon['coupons_max_order'] == 0 ? '1.00' : $this->coupon['coupons_max_order'] / ( tep_add_tax( $product['final_price'] * $product['qty'], $product['tax'] ) * $product_count ) );
	  $applied_discount = tep_add_tax( $product['final_price'] * $max_applied_percentage * $this->coupon['coupons_discount_percent'], $product['tax'] ) * $product['qty'];
	}

 

It's better then what it was but still it's only 2/3 of the discount not the total amount. Your help is appreciated.

Edited by gollo
Link to comment
Share on other sites

Hi There,

 

I seem to have a problem that i can not fix myself.

 

I read en search the topic for my problem but i did not find the solution.

 

I get this error page between page Checkout Payment and Checkout Confirmation.

 

Warning: main(): open_basedir restriction in effect. File(/home/httpd/vhosts/dwcarstyling.nl/httpdocs/includes/classes/discount_coupon.php) is not within the allowed path(s): (/home/httpd/vhosts/dwcarstyling.nl/httpsdocs:/tmp) in /home/httpd/vhosts/dwcarstyling.nl/httpsdocs/includes/modules/order_total/ot_discount_coupon.php on line 14

 

Warning: main(/home/httpd/vhosts/dwcarstyling.nl/httpdocs/includes/classes/discount_coupon.php): failed to open stream: Operation not permitted in /home/httpd/vhosts/dwcarstyling.nl/httpsdocs/includes/modules/order_total/ot_discount_coupon.php on line 14

 

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

 

I have done everythink in my power off but i do not now what to do now.

 

I hope some body can help my whit this error.

 

Beste Regard Dennis

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