Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Discount Coupon Codes


kgt

Recommended Posts

Is there a way with this contrib to apply a discount individually to multiple items at the same time? For example, I would like to create a coupon that applies to a group of items. However, that coupon would discount, say $5, from each individual item from that group when placed in the shopping cart not the total price. So if items A,B, and C were in the group but item D was not, and when the customer orders items A,B,C, and D, the price of A is reduced by $5 as well as B and C but item D is at the regular price. Thanks.

Link to comment
Share on other sites

Is there a way with this contrib to apply a discount individually to multiple items at the same time? For example, I would like to create a coupon that applies to a group of items. However, that coupon would discount, say $5, from each individual item from that group when placed in the shopping cart not the total price. So if items A,B, and C were in the group but item D was not, and when the customer orders items A,B,C, and D, the price of A is reduced by $5 as well as B and C but item D is at the regular price. Thanks.

 

Just to clarify, I understand this can be done with percentage discounts applied to included items, but can it be done with a fixed

amount off each individual item instead of the total sale?

Link to comment
Share on other sites

I tried installing the latest version (3.34) and the contribution appears to be incomplete; it's missing the file includes/functions/coupons.php. If I could get that file, I would REALLY appreciate it, since the contribution is partially installed now and I'm stuck.

 

Thanks!

 

Jim

Link to comment
Share on other sites

I tried installing the latest version (3.34) and the contribution appears to be incomplete; it's missing the file includes/functions/coupons.php. If I could get that file, I would REALLY appreciate it, since the contribution is partially installed now and I'm stuck.

 

Thanks!

 

Jim

 

My mistake - misread the error

Link to comment
Share on other sites

Hi,

 

I'm running 3.31 of DCC. How do I upgrade to 3.34 without doing a full install? I want to be sure to keep all the current coupon codes intact.

 

Thanks!

 

Jon

 

Anyone have any feedback on this? Just curious what I ought to do.

 

Thanks!

 

Jon

Link to comment
Share on other sites

Hi all,

I have looked through this thread and have not found an answer to my question, I hope that you are able to help.

 

I need to figure out how to apply a specific discount per a voucher code to any item.

 

EX. Customer receives and email for voucher code 1234 and this will get them 10% off any 1 item on the site.

The customer then comes to the site and enters the voucher, purchases 6 products and I want to apply the 10% off to the most expensive item.

 

Have any of you done anything like this before? If you have I would like to hear any feedback that you have.

 

Thanks!

 

Jessy71

Link to comment
Share on other sites

Hi, I have installed this contribution -> http://addons.oscommerce.com/info/4269 (V3.34 - 2nd Error - database_table.php) And it seems that everything is properly installed and almost everything works fine unless the area of "Shipping exclusion zone" because when I add a zone and give it to accept I get the following error:

 

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

 

INSERT INTO discount_coupons_to_zones VALUES ( "1234", 4 )

 

[TEP STOP]

 

The truth is that I have no idea that it can be ..

 

If someone could help me .. Thanks.

Edited by jhgraphic
Link to comment
Share on other sites

Hi KG Thorson.

 

First of all, thank you for this great contribution. It is exactly what I needed.

 

 

 

I have run into a little problem though. And I haven't been able to find the problem myself. I hope you can help me. It's the same problem some other people here seem to have.

 

When i enter correct coupon code but not for that category (i mean i have given exclusion on that category from admin panel) it redirects to login page even though i am already loged in.

 

Can you guide me for this?

 

Your help will be appreciated.

 

Dipan

Link to comment
Share on other sites

I just added this contribution and when i go to check out it goes to this error:Fatal error: Call to undefined function tep_get_categories_name() in /home2/blackrp4/public_html/includes/modules/shipping/freecats.php on line 71

 

I have another contribution installed called free shipping by cats, which had never given me any problems until i installed this contribution. I am new to code so have no idea how to fix does anyone have any ideas how to fix or why it is interfering with discount coupon codes?

 

Another thing is when i was editing catalog/includes/classes/order.php

when looking for: $shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty']; $this->info['subtotal'] += $shown_price;

 

I could not find it so that may be the stem of the problem?

i have this:

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

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

Edited by risela
Link to comment
Share on other sites

I just added this contribution and when i go to check out it goes to this error:Fatal error: Call to undefined function tep_get_categories_name() in /home2/blackrp4/public_html/includes/modules/shipping/freecats.php on line 71

 

I have another contribution installed called free shipping by cats, which had never given me any problems until i installed this contribution. I am new to code so have no idea how to fix does anyone have any ideas how to fix or why it is interfering with discount coupon codes?

 

Another thing is when i was editing catalog/includes/classes/order.php

when looking for: $shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty']; $this->info['subtotal'] += $shown_price;

 

I could not find it so that may be the stem of the problem?

i have this:

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

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

 

I figure it out!

Link to comment
Share on other sites

Hi all,

 

I am using DCC 3.34 on (I think) MS2.2 RC2 but have a problem.

Have been looking into debug text but not tax seems to be applied to the coupon. I'm mainly after free shipping coupons for now but probably will be using coupons for other stuff. As the free shipping does not take tax into account, I am using a workaround of setting the shipping discount to 119% (vat is 19% here).

So what happens now is this:

 

Order amount (incl vat) 119,00 -> products 100,00 + 19% vat

Shipping amount 11,90 -> shipping 10,00 + 19% vat

VAT amount (19%) 20,90 -> 19,00 on products, 1,9 on shipping

Discount code applied 11,90 -> 119% of 10,00 shipping

 

The problem being that whilst the total amount now shows correctly as a result of my Q&D workaround, the VAT amount on the invoice is incorrect (should be 19,00).

 

Has anybody encountered this problem and do you have a solution to have the discount code taxed correctly?

 

Any input is greatly appreciated.

 

Wiljo

Link to comment
Share on other sites

As wvlenthe already pointed in;

 

When using Shipping discount, TAX is not calculated ok !

Seems like the amount of shipping discount is not subtracted from the order total for the TAX calculation. But only when using Shipping discount.

I run out of ideas ... :(

Please someone have a look at this and post some reply.

 

TNX a lot !!!

 

 

As for the issue that TAX is not added to the discounted shipping amount:

 

You can add the tax directly in the code;

 

find in:

includes/classes/discount_coupon.php

 

arround line 400 after //bugfix by xinxi

 

$this->applied_discount['shipping'] =  ($info['shipping_cost'] * $this->coupon['coupons_discount_amount']);

 

and replace with

 

$this->applied_discount['shipping'] =( ($info['shipping_cost'] * $this->coupon['coupons_discount_amount'])+(($info['shipping_cost'] * $this->coupon['coupons_discount_amount'])*0.2)  );

 

where 0.2 is 20% VAT ... and just change it to fit your VAT ...

 

 

Gregor

Link to comment
Share on other sites

I think it's a nice add on, but I'm a bit scared about the installation and that I fail, because of my minimal SQL/php knowledges...

the installation seems not to be so simple..I don't wanna risk the my osc installation, as it runs that smooth actually..

and finally, I see here here too many problems and too less aswers...

Link to comment
Share on other sites

I'm a bit scared about the installation and that I fail

Hello QuasiMoto,

 

My PHP skills are basic and I have managed to install this contribution.

The instructions are quite straightforward and easy to follow.

I have installed the 3.34 version on OSC 2.2 and apart from the above problem with tax calculation in case of free shipping, the contribution works fine.

 

What I always do is take a full backup from my shop (including the database via phpmyadmin).

Then I created an extra set of directories in the correct hierarchy where I put all the files needed for install and I change them there.

After completion of the manual, I send the changed files over via ftp.

If anything goes wrong, you can restore your backup and you are back where you started.

 

I must admit that I have a test shop as well where I usually install prior to installing to my live shops but the idea and procedure is the same.

 

regards,

 

Wiljo

Link to comment
Share on other sites

I think it's a nice add on, but I'm a bit scared about the installation and that I fail, because of my minimal SQL/php knowledges...

the installation seems not to be so simple..I don't wanna risk the my osc installation, as it runs that smooth actually..

and finally, I see here here too many problems and too less aswers...

 

 

Actualy the contribution is working perfect with the exception of function for discount at shipping where tax is not calculated ok. But this option was added to coupons later as I could figure out. I just disabled the Shipping from drop down menu until some fix arrives. Without this option the contribution is still very useful and working great. You just have to be careful with the configuration options.

Follow the instructions carefuly and if you have other contributions installed, do not copy any files except new ones. Make changes manualy and be careful with line numbers as they may vary. The contrubutions are mostly using new install line numbers. If you are less skilled you can try some compare sw like WinMerge for file comparing.

Try it and have fun ! ;)

Link to comment
Share on other sites

I have a vry strage problem, everything installed fine and working, but the problem that annoys me is that the coupons.php page and other from this contribution is showing outside the borders, this is 2.6 on osc 2.3.1 running sparx's admin.. below is a scrrenshot

 

problem.png

Link to comment
Share on other sites

I have a vry strage problem, everything installed fine and working, but the problem that annoys me is that the coupons.php page and other from this contribution is showing outside the borders, this is 2.6 on osc 2.3.1 running sparx's admin.. below is a scrrenshot

 

problem.png

 

 

Hi,

 

it must be a conflict with "sparx's admin" as it's all showing OK with the usual admin. Check some hard coded height/width in coupons.php and other related files and also check css if there is any table dimmensions conflict, etc ...

Link to comment
Share on other sites

Hi,

 

Yes, I've come up with a solutions that works (finally).

This solves the problem with subtotals showing with the discount applied, even when Display subtotal with applied discount? is set to false.

 

includes/classes/discount_coupon.php ~line 368

 

Find:

if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'false' ) {
       //we don't want to display the subtotal with the discount applied, so apply the discount then set the applied_discount variable to zero so that it's not added into the order subtotal, but is still used to correctly calculate tax
       $actual_shown_price = ( $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'] ) - ( $discount['applied_discount'] + $discount['discount_tax'] );
       $applied_discount = 0;
     }
     $shown_price = ( $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'] ) - ( $discount['applied_discount'] + $discount['discount_tax'] );

 

Replace with:

      if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'false' ) {
       //we don't want to display the subtotal with the discount applied, so apply the discount then set the applied_discount variable to zero so that it's not added into the order subtotal, but is still used to correctly calculate tax
       $actual_shown_price = ( $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'] ) - ( $discount['applied_discount'] + $discount['discount_tax'] );
       $applied_discount = 0;
       $shown_price = $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'];
     } else {
       $shown_price = ( $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'] ) - ( $discount['applied_discount'] + $discount['discount_tax'] );
     }

Can anybody confirm this actually works. I have made this change to version 3.2, but still have the exact same result. I still have the discount displayed in the subtotal. Since I don't see any more comment on this I assume it works in at least one version of the contrib.

I run a completely customized osC2.2 RC1 shop with mostly custom modifications that replicate the features of many contributions available except in a way that the data is more easily synced with Quickbooks on a continuous basis.

Link to comment
Share on other sites

Can anybody confirm this actually works. I have made this change to version 3.2, but still have the exact same result. I still have the discount displayed in the subtotal. Since I don't see any more comment on this I assume it works in at least one version of the contrib.

Hi jsalis,

 

The code listed is exactly what is in version 3.34 (which is what I am using).

Changing this setting has an effect on my shop.

My shop is set to display subtotal including discount.

When set to false the subtotal reads the total goods amount.

When set to true the subtotal reads the total goods amount minus discount.

 

The tax calculation goes wrong in my case though, playing around with the Display tax in discount line? setting only changes the amounts but it is still wrong.

Tax calculation is spot on with settings:

Display subtotal with applied discount? -true

Display tax in discount line? -Display discount with discounted tax applied

Display discount total lines for each tax group? -false

AND with Suhy's mod as mentioned in the above post from December 29 in place.

 

good luck.

 

Wiljo

Link to comment
Share on other sites

Can anybody confirm this actually works. I have made this change to version 3.2, but still have the exact same result. I still have the discount displayed in the subtotal. Since I don't see any more comment on this I assume it works in at least one version of the contrib.

Ok I figured this one out. Instead of this:

      if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'false' ) {
       //we don't want to display the subtotal with the discount applied, so apply the discount then set the applied_discount variable to zero so that it's not added into the order subtotal, but is still used to correctly calculate tax
       $actual_shown_price = ( $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'] ) - ( $discount['applied_discount'] + $discount['discount_tax'] );
       $applied_discount = 0;
       $shown_price = $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'];
     } else {
       $shown_price = ( $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'] ) - ( $discount['applied_discount'] + $discount['discount_tax'] );
     }

It should be this:

      if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'false' ) {
       //we don't want to display the subtotal with the discount applied, so apply the discount then set the applied_discount variable to zero so that it's not added into the order subtotal, but is still used to correctly calculate tax
       $actual_shown_price = ( $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'] ); // - ( $discount['applied_discount'] + $discount['discount_tax'] ); Comment out this part
       $applied_discount = 0;
       $shown_price = $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'];
     } else {
       $shown_price = ( $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'] ) - ( $discount['applied_discount'] + $discount['discount_tax'] );
     }

The $actual_shown_price was in fact being used, but it was performing essentially the same calculation as $shown_price. After commenting the part of that calculation that subtracted the discount and added the tax not only do I see the subtotal without the discount applied it is also used for my table rate shipping, which was the entire reason I needed the subtotal to reflect the pre-discounted price. My table rates are based on price and the subtotal was being reduced by the discount prior to the shipping calculation being made which is a percentage of that subtotal. Of course none of this was an issue until I implemented one page checkout. The standard checkout forced shipping selection prior to discount validation. With one page checkout this can occur in any order. Something to be aware of if you are considering the One Page Checkout contribution with this discount coupon contribution.

I run a completely customized osC2.2 RC1 shop with mostly custom modifications that replicate the features of many contributions available except in a way that the data is more easily synced with Quickbooks on a continuous basis.

Link to comment
Share on other sites

Hi jsalis,

 

The code listed is exactly what is in version 3.34 (which is what I am using).

Changing this setting has an effect on my shop.

My shop is set to display subtotal including discount.

When set to false the subtotal reads the total goods amount.

When set to true the subtotal reads the total goods amount minus discount.

 

The tax calculation goes wrong in my case though, playing around with the Display tax in discount line? setting only changes the amounts but it is still wrong.

Tax calculation is spot on with settings:

Display subtotal with applied discount? -true

Display tax in discount line? -Display discount with discounted tax applied

Display discount total lines for each tax group? -false

AND with Suhy's mod as mentioned in the above post from December 29 in place.

 

good luck.

 

Wiljo

Thanks for the information I am using the 3.32 and used the auto installer, but have modified the contribution twice; once to accommodate a custom auto discount module I built to automatically generate and send coupons that can be used by this module when a customer makes a qualifying order and again to accommodate the One Page Checkout contribution. Could be why I saw no effect, but after looking at the code in question and how the function is called and used in the catalog/includes/classes/order.php order class cart() function I just don't see how it could possibly work. Apparently I would need to see how ver.3.34 is coded. Oh well it is working now and an alternative is posted.

Seems like I had similar issues getting taxes working when I first implemented this contribution. My settings are:

Enable discount coupon?

true

 

Sort Order

2

 

Display discount with minus (-) sign?

true

 

Display subtotal with applied discount?

false

 

Display tax in discount line?

None

 

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

 

It works fine now, but I can't recall what the tax issue was exactly or how I fixed it.

I run a completely customized osC2.2 RC1 shop with mostly custom modifications that replicate the features of many contributions available except in a way that the data is more easily synced with Quickbooks on a continuous basis.

Link to comment
Share on other sites

Thanks for the information I am using the 3.32 and used the auto installer

[...]

It works fine now, but I can't recall what the tax issue was exactly or how I fixed it.

Glad to hear it works for you!

 

I used the autoinstaller after 3.34 didn't work as expected and it never worked, I went back to 3.34 after that.

 

The original bug Suhi fixed was that in case of a shipping discount, the discount would be displayed without tax with setting Display tax in discount line? set to Display discount with discounted tax applied.

 

The remaining bug is that in case of a shipping discount, the tax on the shipping charge is not subtracted from the total tax amount. So you get the following (assuming 20% tax):

goods amount 120 (incl tax)

discount 100% shipping applied -20 (incl tax)

sub total 100 (incl tax)

shipping 20 (incl tax)

total 120 (incl tax)

tax 23,33

The tax amount being 20% over 100 = 20 plus 20% over 16,66 = 3,33.

 

The tax amount should read 20 being 20% over 100 plus 20% over 16,66 minus 20% over 16,66.

 

If you have an install running now where all discounts are working and the tax calculation of all of them is correct, I would be very interested in your code!

 

Regards,

Wiljo

Link to comment
Share on other sites

Hi, I experience two problems with the contribution

 

Fist problem:

The same error message appears multiple times when trying to use the coupon with some criteria not met. For example I get the message 'The minimum order total for this coupon is 30' 6 times.

 

Second problem:

I have created a coupon and excluded about 1500 products. When I try to buy more than 7 products and I reach checkout_confirmation.php I get this message on Firefox

 

Moved Temporarily

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the the request.

Link to comment
Share on other sites

Glad to hear it works for you!

 

I used the autoinstaller after 3.34 didn't work as expected and it never worked, I went back to 3.34 after that.

 

The original bug Suhi fixed was that in case of a shipping discount, the discount would be displayed without tax with setting Display tax in discount line? set to Display discount with discounted tax applied.

 

The remaining bug is that in case of a shipping discount, the tax on the shipping charge is not subtracted from the total tax amount. So you get the following (assuming 20% tax):

goods amount 120 (incl tax)

discount 100% shipping applied -20 (incl tax)

sub total 100 (incl tax)

shipping 20 (incl tax)

total 120 (incl tax)

tax 23,33

The tax amount being 20% over 100 = 20 plus 20% over 16,66 = 3,33.

 

The tax amount should read 20 being 20% over 100 plus 20% over 16,66 minus 20% over 16,66.

 

If you have an install running now where all discounts are working and the tax calculation of all of them is correct, I would be very interested in your code!

 

Regards,

Wiljo

I think I follow what you are saying, but that is not exactly what I am doing. Possibly we have different taxation requirements, I am in California, here we are not taxing shipping, the shipper taxes us we pass the entire cost of shipping along. The shipping company pays the tax to the state. Anyway I have a product store and a sandbox setup with completely different checkout systems right now. The production store has the default multi-page checkckout and the order total information on a test order I just created looks like this:

1 x Priority Processing 0% $18.00

4 x Batteries, AA Alkaline (100 Pack) 8.25% $185.00

Discount Coupon TestPercent applied: -$18.50

Sub-Total: $184.50

UPS Ground (UPS Ground): $15.95

California: $13.74

Total: $214.19

That is a ten percent discount. The Priority processing is not taxable and specifically excluded from the discount. Note that the batteries are taxable and the tax rate is displayed, but not included in the line item total. The discount is displayed above the subtotal in this case, so I display the subtotal with the discount applied. Then shipping (calculated on the prediscount subtotal) and tax (calculated on the post discount subtotal of taxable items only) is added and a total provided. This meets local requirements. And unless my calculator has issues it is calculated correctly every time. Though I don't think this is exactly the arrangement you are speaking of. Next is a shipping discount.

1 x Priority Processing 0% $18.00

4 x Batteries, AA Alkaline (100 Pack) 8.25% $185.00

Discount Coupon TestShipping applied: -$1.60

Sub-Total: $203.00

UPS Ground (UPS Ground): $15.95

California: $15.26

Total: $232.62

This is not as pretty, but definitely accurate. The order total module and discount module do not work together well enough to change the sort order of the discount line only when a shipping discount is applied. Since it is rare that we offer shipping discounts I went with above the subtotal. Technically in this case the discount is not applied to the subtotal, but applied between shipping and tax despite where it is displayed. the calculation appears to be off by a penny, because of the way the the line items and discount are rounded to the second decimal place. This seems to happen about 25% of the time.

 

In the production environment I also moved the discount code entry from the checkout_payment.php page to the shopping_cart.php page and wrote an AJAX script to validate the code, tell the customer what the discount will be, and save the code in a session variable to be applied on the checkout_confirmation.php page.

 

My cart is highly custom at this point and the code is not easy to integrate into another cart, but I will happily send you the code I used to integrate all or part of the solutions above if you think they will meet your local requirements.

 

My sandbox is using the one page checkout and always displays the subtotal without the discount and displays/applies the discount right after the subtotal line. Otherwise all taxation is setup the same way in the sandbox version which should go to production later this week.

Edited by jsalis

I run a completely customized osC2.2 RC1 shop with mostly custom modifications that replicate the features of many contributions available except in a way that the data is more easily synced with Quickbooks on a continuous basis.

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