Jump to content
kgt

[Contribution] Discount Coupon Codes

Recommended Posts

Think i found a bug, in discount_coupon.php, function total_valid_products, there tax is calculated when DISPLAY_PRICE_WITH_TAX = true but an unknown array $tax_address is used causing tax to be always 0. So while the whole shop may be displaying prices with tax, the coupon-codes modules is calculating discounts always based on prices without tax (and then optionally adding tax again for displaying). All very confusing ...

Paul

Hello Paul,

 

In my opinion, discounts should be calculated without tax to be able to work correctly. You don't want discounts including tax to be given when selling to non-EU countries, but you want to tax EU sales.

 

There is an issue with tax calculation on shipping discounts. If this is the discount you are using, read back a page or two where you will find a fix by Suhy. This is a workaround and certainly not a definitive fix.

 

As to the $tax_address, this variable is set in order.php on line 152 (my version of it anyway).

discount_coupon.php is then called from here in lines 220 and further.

If your tax percentage always comes back zero and you are not testing with shipping discount, I would say you need to check your tax setup. There is a good topic on the dutch forum on this by Berkedam).

 

HTH

 

Wiljo

Share this post


Link to post
Share on other sites

Hello Paul,

 

In my opinion, discounts should be calculated without tax to be able to work correctly. You don't want discounts including tax to be given when selling to non-EU countries, but you want to tax EU sales.

 

There is an issue with tax calculation on shipping discounts. If this is the discount you are using, read back a page or two where you will find a fix by Suhy. This is a workaround and certainly not a definitive fix.

 

As to the $tax_address, this variable is set in order.php on line 152 (my version of it anyway).

discount_coupon.php is then called from here in lines 220 and further.

If your tax percentage always comes back zero and you are not testing with shipping discount, I would say you need to check your tax setup. There is a good topic on the dutch forum on this by Berkedam).

 

HTH

 

Wiljo

 

Customers expect discount to be incl. tax; or in fact customers are only interrested in nett. prices incl tax, since that is what they need to pay. It's rather strange to give a customer 5$ discount while in fact its 5,95$ discount incl tax...!?

 

Regarding the $tax_address, yes it's in order.php but shouldn't it be declared global in the total_valid_products function?

 

Paul

Share this post


Link to post
Share on other sites

Customers expect discount to be incl. tax; or in fact customers are only interrested in nett. prices incl tax, since that is what they need to pay. It's rather strange to give a customer 5$ discount while in fact its 5,95$ discount incl tax...!?

 

Regarding the $tax_address, yes it's in order.php but shouldn't it be declared global in the total_valid_products function?

 

Paul

Hi Paul,

 

You are totally correct when you say customers want prices including tax. I'm merely saying calculation needs to be on the base price to be able to allow for multiple tax rates. DCC works for me displaying discounts including taxes on checkout (well, except for the (free) shipping discount), the customer doesn't get bothered with tax. The only thing I have to remember is to define the discount without tax (I have added an extra text to the discount input page as a reminder).

 

About $tax_address; My php is not as good as my dutch, but as it is 'require'-d, doesn't that mean the required file functions as if it is inserted instead of required? I use this construction a lot designing website and never declare the variables passed downwards as global. For testing purposes you can put a print_r in there just to see what happens.

 

regards,

 

Wiljo

Share this post


Link to post
Share on other sites

You are totally correct when you say customers want prices including tax. I'm merely saying calculation needs to be on the base price to be able to allow for multiple tax rates. DCC works for me displaying discounts including taxes on checkout (well, except for the (free) shipping discount), the customer doesn't get bothered with tax. The only thing I have to remember is to define the discount without tax (I have added an extra text to the discount input page as a reminder).

 

Wiljo,

 

If i want give EUR 5 discount (incl tax), i may need to enter 4,20 (excl 19% tax) or 4,72; or anything in between since customer may order 19% tax'ed items and/or 6% items. So it doesn't work on the base price...?

 

Regarding the $tax_address; if i die/print_r, i see its simply not defined, even when i declare it global, it's not defined. I do have it in classes/order.php but there its a local as well. See also php.net

 

Paul

Share this post


Link to post
Share on other sites

This module is working great but I have a customer that wants to give a coupon that enables $5 off plus free shipping. Is there any way to do this with the current code? I didn't see a way and started to modify the discount coupon class but I don't follow the code exactly and aren't sure where the various amounts are being calculated. I also tried modifying the primary key of the db to allow 2 coupons with the same name (so i could set one to fixed and another to shipping but that didnt work so i reverted that).

 

I do have some php/mysql knowledge so if you can point me in the right direction I think I should be able to code it myself. Any help is appreciated! Thanks!

Share this post


Link to post
Share on other sites

This module is working great but I have a customer that wants to give a coupon that enables $5 off plus free shipping. Is there any way to do this with the current code? I didn't see a way and started to modify the discount coupon class but I don't follow the code exactly and aren't sure where the various amounts are being calculated. I also tried modifying the primary key of the db to allow 2 coupons with the same name (so i could set one to fixed and another to shipping but that didnt work so i reverted that).

 

I do have some php/mysql knowledge so if you can point me in the right direction I think I should be able to code it myself. Any help is appreciated! Thanks!

Hi R,

 

First of all; if you get free shipping running with correct calculation of taxes, please say so. There are a number of people on here who'd love to get it to work correctly.

 

Second, as to what you describe above:

1. I think my choice would be to create an extra discount option, free shipping plus fixed amount. Murphy's Law says your customer will be asking for whatever you disabled, changed or coded out the minute you have coded it out. ;-)

 

It may be helpful to try the debug mode, it helped me with deducing what is calculated where in the discount_coupon.php class.

 

IIRC the various amounts are calculated in discount_coupon.php and the taxation is done in order.php.

 

Please keep us posted on the results, always nice to have an extra possibility.

 

HTH

regards,

 

Wiljo

Share this post


Link to post
Share on other sites

Found another issue; display prices with tax = 'true', then create an order of 5$ + shipping of 3$ (for example), include discount coupon fixed 10$, in the total/confirmation page you will notice that the total price isn't 0 but equal to the tax of products + shipping.

 

It's the ot_'s that add the tax to the $info['total'].

 

I'm working on a hack to correct the 'total' from the ot_discount_coupon::process(); moving finalize_discount here seems to do the trick but i have no clue what impact of such change may be; since the modules are also used by admin...!?

 

Paul

Share this post


Link to post
Share on other sites

Found another issue; display prices with tax = 'true', then create an order of 5$ + shipping of 3$ (for example), include discount coupon fixed 10$, in the total/confirmation page you will notice that the total price isn't 0 but equal to the tax of products + shipping.

 

I have tried to reproduce this.

My result is that the total price is tax on shipping only:

Goods amount (incl tax): € 1,50

Discount Coupon WiljoTest verwerkt: -€ 23,80

Sub-Totaal: € -22,30

DHL verzekerde verzending: € 3,25

Totaal: € 0,52

 

(3,25 x 19/119 = 0,518)

 

BUT I have changed the code in catalog/classes/discount_coupon.php (around line 400) to add the tax on shipping as it wasn't calculated correctly. This could be the cause here.

So I cannot reproduce this problem with my install/settings.

 

Pls let us know how you get on?

 

Wiljo

Share this post


Link to post
Share on other sites

"Discount Coupon" does not appear in the list of Order Total modules under Modules > Order Total in the admin section.

 

I've doubled checked that

catalog/includes/modules/order_total/ot_discount_coupon.php

catalog/includes/languages/english/modules/order_total/ot_discount_coupon.php

 

are on their respective folders.

 

An still Discount Coupon does not appear.

 

I'm on oscommerce 2.3.1, and using the respective Patches.

 

v3.34 SPPC Mod 18 Feb 2011

v3.34 SPPC Mod 17 Feb 2011

v3.34 Admin SpiffyCal 17 Feb 2011

Discount Coupon Codes 3.34 for osc 2.31 26 Nov 2010

Share this post


Link to post
Share on other sites

I've installed the Discount Coupon Codes Contribution but the module is not appearing in Admin > Modules > Order Total.

 

I did see this in the Common Problems section of the README file:

 

# "Discount Coupon" does not appear in the list of Order Total modules under Modules > Order Total in the admin section.

Ensure that you have uploaded the module files contained in the contribution package:

catalog/includes/modules/order_total/ot_discount_coupon.php

catalog/includes/languages/english/modules/order_total/ot_discount_coupon.php

 

I've verified that each of the 2 files mentioned above are in the proper locations.

 

Here's what I see in Modules > Order Total right now:

 

Low Order Fee

Shipping 2 Info

Sub-Total 1 Info

Tax 3 Info

Total 4 Info

 

I've gone through the instructions twice, and verified that everything is correct, but I've obviously missed something.

 

Can anyone help?

Share this post


Link to post
Share on other sites

I've installed the Discount Coupon Codes Contribution but the module is not appearing in Admin > Modules > Order Total.

 

I did see this in the Common Problems section of the README file:

 

# "Discount Coupon" does not appear in the list of Order Total modules under Modules > Order Total in the admin section.

Ensure that you have uploaded the module files contained in the contribution package:

catalog/includes/modules/order_total/ot_discount_coupon.php

catalog/includes/languages/english/modules/order_total/ot_discount_coupon.php

 

I've verified that each of the 2 files mentioned above are in the proper locations.

 

Here's what I see in Modules > Order Total right now:

 

Low Order Fee

Shipping 2 Info

Sub-Total 1 Info

Tax 3 Info

Total 4 Info

 

I've gone through the instructions twice, and verified that everything is correct, but I've obviously missed something.

 

Can anyone help?

 

 

Disregard. I found my problem.

 

I have 2 versions of the site in question set up locally - a "live" version and a "dev" version.

 

I installed the contribution on the dev site, but the config file in the Admin was pointing to the live site. Since the config was pointing to the live site, and I installed the contribution on the dev site, I wasn't seeing the Module in the admin tools.

 

One of those days.

Share this post


Link to post
Share on other sites

I have tried to reproduce this.

<...>

 

Hoi Wiljo,

 

Might be that i was seeing the tax on giftwrap + tax on shipping (iso tax on products).

 

It's wrong anyway,,,,

 

I guess i need to refactor simply the workings on discount_coupons the class + integration into the order.

 

Thing is that each ot-contribution is hacked differently into the codebase :( It's a mess :(

 

BTW: Have you tried to use the order_editor (contribution) icw added ot's? Try to update the order-total items and see what happens....

 

Paul

Share this post


Link to post
Share on other sites

Hoi Wiljo,

 

[...]I guess i need to refactor simply the workings on discount_coupons the class + integration into the order.

 

[...]BTW: Have you tried to use the order_editor (contribution) icw added ot's? Try to update the order-total items and see what happens....

 

Paul

Hoi Paul,

 

Although I have got an order editor installed into my shops, I haven't tried fiddling with other ot's like DCC. I think without a very thorough understanding of how OSC works, one could never develop a contribution that works flawless with any other. To my opinion, OSC is not documented enough and not automated enough to allow developers to either build with minor knowledge or build with great expertise. And there's always the possibility that another bad-written mod will ruin the whole cart.

 

I have seen some of the coding and not everything makes sense to me. I have even tried to fix the free shipping part but am stuck somewhere.

 

Having said all that, if you are really going to dive into dcc I'd be happy to help you. My php skills are getting better but they are by no means good. I could help you with testing and evaluation though. If you are interested, drop me a pm.

 

groeten,

 

Wiljo

Share this post


Link to post
Share on other sites

Hi all,

 

I've installed this contribution in my osCommerce 2.2 shop. I can add coupons in the admin panel, the form shows at the checkout_payment page, but when I fill in a coupon code, and go to checkout_confirmation, the coupon has not been calculated in the order. A wrong code also takes me to the confirmation page, so it doesn't show any error.

 

I've tried some of the fixes which I found in this topic, but still it's not working properly.

 

Anyone got any thoughts on this?

 

Greetings,

 

Eric

Share this post


Link to post
Share on other sites

Nevermind, i fixed the problem, if anyone has a simmilar problem, here's the fix.

 

find

 

   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
     <tr>
       <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="specialPrice" align="right">NOTICE: <a href="<?php echo tep_href_link( DIR_WS_LANGUAGES.$language.'/'.FILENAME_DISCOUNT_COUPONS_MANUAL ).'">'.HEADING_TITLE_VIEW_MANUAL; ?></a></td>

 

replace with

 

<table>
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
     <tr>
       <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="specialPrice" align="right">NOTICE: <a href="<?php echo tep_href_link( DIR_WS_LANGUAGES.$language.'/'.FILENAME_DISCOUNT_COUPONS_MANUAL ).'">'.HEADING_TITLE_VIEW_MANUAL; ?></a></td>

 

Hi! Hi!

 

Are you sure the fix works? Because I see that both texts are equal.

 

Could you check? Since I also I have the same problem and do not know how to fix it.

 

Thanks for all.

Share this post


Link to post
Share on other sites

I am having troubles with the minimum order part of the discount coupon codes. I have it set so that the coupon does not apply unless their order is over $50. But it allows it even if the order is under $50. Ideally I would like it so that the order total before taxes and shipping is $50 for the coupon to work. Here is what I have setup:

 

Coupon Code: 111-111

Discount Amount: 50.00 Discount Type: Fixed Amount

Start Date: 03/18/2011

End Date: 03/18/2012

Max Use: 1

Min Order: 50.00 Min Order Type: Price Total

Number Available: 1

 

Then my cart looks as follows if I try and use it:

 

Subtotal: 9.99

Shipping: 7.99

Taxes: .90

Total: 18.88

Coupon Code 111-111: -50.00

 

Total: -31.12

 

Any want to fix this? It seems to be totally ignoring my min order setting. I have about 230 of these coupons going out so I would love to get this fixed:) Any help would be appreciated.

 

Thanks!

Krista

Share this post


Link to post
Share on other sites

With my most recent coupon code mtn2011 this module has been failing this week and I don't know why. About half the time when a customer moves on to Pay Pal (or finalises the order to the success page with a manual cheque or bank transfer payment), the discount is not applying and their order total resumes to what it'd be without the coupon.

 

This is happening with all payment modules, cheque, money order, bank transfer and Pay Pal, so I do not believe the problem is with a payment module.

 

Anyone know how this would suddenly stop working half the time?

 

It's driving me and my customers a little nuts and I'd like to solve it.

Edited by SamyT

Share this post


Link to post
Share on other sites

I am having problems with this cont....

 

I have installed and resinstalled, checked everythink over and over but I can't find it....

 

I use version:Discount Coupon Codes 3.34

and oscommerce: 2.2

 

As of what I can see is that it is working for example:

when entering a wrong code I get the error message. So I assume that till so far it is working great!

But now moving on to the next screen there is no discount or anything. I can't see it is added in the sub total nor in the total amount.... What am I doing wrong? debug mode isn't that mutch of a option becouse it isn't showing any error.... Also checkt the checkout_confirmation.php dubble but I can't find it. Can anyone help me ? what should I post here(of my php scripts)?

Share this post


Link to post
Share on other sites

I have applied this contribution to my store today and in the "checkout_payment.php" file i noticed a problem with the text box label and context heading..

it displays it like such on my web page:

 

 

TABLE_HEADING_COUPON

 

ENTRY_DISCOUNT_COUPON (and the input box right here

 

http://www.getmaxxed.com/catalog/checkout_payment.php

 

This doesnt seem like this is the way it is supposed to display... This is part of the code being displayed...

 

Also, everything else seems to be fine, I enabled coupons in my admin, but it doesnt show up under "catalog" in the admin panel.

 

I have verified the files are there and the tables have been added to my db..

 

Any ideas?


OSC Version 2.3.1

 

Add ons installed:

 

Coupons

SEO URLS 5

Fedex Ship

USPS

Paypal Express

Slideshow

Share this post


Link to post
Share on other sites

I have applied this contribution to my store today and in the "checkout_payment.php" file i noticed a problem with the text box label and context heading..

it displays it like such on my web page:

 

 

TABLE_HEADING_COUPON

 

ENTRY_DISCOUNT_COUPON (and the input box right here

 

http://www.getmaxxed.com/catalog/checkout_payment.php

 

This doesnt seem like this is the way it is supposed to display... This is part of the code being displayed...

 

Also, everything else seems to be fine, I enabled coupons in my admin, but it doesnt show up under "catalog" in the admin panel.

 

I have verified the files are there and the tables have been added to my db..

 

Any ideas?

 

 

Ok... I just realized someof the files were not edited with a code editor... so the line formatting was screwed up... all of that is good now


OSC Version 2.3.1

 

Add ons installed:

 

Coupons

SEO URLS 5

Fedex Ship

USPS

Paypal Express

Slideshow

Share this post


Link to post
Share on other sites

Now I have a new problem... My coupons.php in my admin is not sized correctly and there is a page error in iexplorer...

 

 

Webpage error details

 

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; AskTB5.4)

Timestamp: Wed, 6 Apr 2011 19:48:14 UTC

 

 

Message: Object expected

Line: 35

Char: 1

Code: 0

URI: http://www.getmaxxed.com/catalog/admin/coupons.php?page=0&action=new


OSC Version 2.3.1

 

Add ons installed:

 

Coupons

SEO URLS 5

Fedex Ship

USPS

Paypal Express

Slideshow

Share this post


Link to post
Share on other sites

Hello everyone. First of all, excuse my English. It's too bad: (sorry.

 

I have installed the contribution and work properly, while not display prices with taxes. Because if I show prices including taxes and makes me the wrong tax calculations.

 

This is an example of what happens to me. You can tell me something?? Please is very important! I've been watching this post, but I have not found the solution. :'(

 

Product: 40.00€

 

Discount Coupon

AVBU7K applied: -12.00€

 

Subtotal: 28.00€

18% I.V.A.: 4.27€

shipping: 0.00€

 

_________________________

 

Total: 32.27€

Share this post


Link to post
Share on other sites

I know it's been an on-going problem with Paypal; did anyone get to pass the discount to PayPal with no problem? I tested with the code below, but still couldn't get it worked. I installed the coupon code 3.34 version on my OSC 2.2 and installed the module fix. Everything works perfect until I get to the Paypal page as the last step to complete the transaction.

 

I'm a newbie in php; your advice will be veryyy appreciated!

 

Thanks!

 

Hi, I am not sure if this is what you are needing as it has been quite some time since I installed this module and my memory is not good, but it may help. Anyway, check in your paypal_ipn.php file or whatever paypal file you use (under includes/modules/payment) and see if the following code is in there:

 

//kgt - discount coupons

if( tep_session_is_registered( 'coupon' ) && $order->info['coupon'] != '' ) {

$sql_data_array = array( 'coupons_id' => $order->info['coupon'],

'orders_id' => $order_id );

tep_db_perform( TABLE_DISCOUNT_COUPONS_TO_ORDERS, $sql_data_array );

}

//end kgt - discount coupons

 

In my file that comes after this:

 

tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

 

Then further down in that file make sure you have the discount coupon code in this section as well:

 

// unregister session variables used during checkout

tep_session_unregister('sendto');

tep_session_unregister('billto');

tep_session_unregister('shipping');

tep_session_unregister('payment');

tep_session_unregister('comments');

//kgt - discount coupons

tep_session_unregister('coupon');

//end kgt - discount coupons

 

tep_session_unregister('cart_PayPal_IPN_ID');

 

I hope that is some help. I must get some sleep now as I am very tired and hope that made sense. If that doesn't work I would suggest doing a search for the type of PayPal addon you use and see if the info is in that discussion to configure it with discount coupons.

Share this post


Link to post
Share on other sites
Hello everyone. First of all, excuse my English. It's too bad: (sorry.

 

I have installed the contribution and work properly, while not display prices with taxes. Because if I show prices including taxes and makes me the wrong tax calculations.

 

This is an example of what happens to me. You can tell me something?? Please is very important! I've been watching this post, but I have not found the solution.

 

Product: 40.00€

 

Discount Coupon

AVBU7K applied: -12.00€

 

Subtotal: 28.00€

18% I.V.A.: 4.27€

shipping: 0.00€

 

_________________________

 

Total: 32.27€

 

 

I found a solution that can apply to stores that display their products including tax. Or at least it works for me. I leave you here to see what you think this little tweak.

open the file catalog/includes/classes/order.php

Find:

//kgt - discount coupon
     if( is_object( $this->coupon ) ) {
       $this->info['total'] = $this->coupon->finalize_discount( $this->info );
     }
     //end kgt - discount coupon

 

Replace:

 

//kgt - discount coupon MODIFICADO PARA MOSTRAR PRECIOS CON IMPUESTOS
     if( is_object( $this->coupon ) ) {
       $this->info['subtotal'] = $this->coupon->finalize_discount( $this->info ) - $this->info['tax'] - $this->info['shipping_cost'];
     }
     //end kgt - discount coupon MODIFICADO PARA MOSTRAR PRECIOS CON IMPUESTOS.

 

The module configuration:

 

Enable discount coupon?

true

 

Sort Order

0

 

Display discount with minus (-) sign?

true

 

Display subtotal with applied discount?

true

 

Display tax in discount line?

Display discounted tax in separate line

 

Exclude product specials?

true

 

Random Code Length

6

 

Display discount total lines for each tax group?

false

 

Allow negative order total?

false

 

Use the language file to format display string?

false

 

Display Format for Order Total Line

Discount Coupon

 applied

 

Debug Mode

false

 

 

If I put a fixed amount of discount given me problems with other sources of gift (get_1_free), (Dangling Carrot) if they work at the same time ... but if I put a discount rate works correctly.

Edited by 2 estilos

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

×