Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Discount Coupon Codes


kgt

Recommended Posts

Okay its not the tables the geo_zone_id is not getting passed to the query???

 

Now I just need to find which query that is???

 

Any help will be appreciated..

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 'or z2g.zone_id = 0 or z2g.zone_id IS NULL ) ' at line 5

 

SELECT dc2z.geo_zone_id FROM discount_coupons_to_zones dc2z LEFT JOIN zones_to_geo_zones z2g USING( geo_zone_id ) WHERE ( z2g.zone_id= or z2g.zone_id = 0 or z2g.zone_id IS NULL ) AND ( z2g.zone_country_id= or z2g.zone_country_id = 0 ) AND dc2z.coupons_id="CouponCode"

 

[TEP STOP]

 

HERE is the solution to above error:

 

I got it working, The cart had been crashing on virtual only products with a 1064 SQL Syntax that many others were also getting change the following:

 

In checkout_shipping find:

 

// if the order contains only virtual products, forward the customer to the billing page as
// a shipping address is not needed
 if ($order->content_type == 'virtual') {
   if (!tep_session_is_registered('shipping')) tep_session_register('shipping');
   $shipping = false;
   $sendto = $customer_default_address_id;
// not $sendto=false to work with shop using Discount Coupon Codes
   tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
 }

 

Allows use of discount coupons with virtual products.

Link to comment
Share on other sites

One more problem I have noticed that needs to be fixed if you are running OsC RC2 is that the catalog/admin/includes/database_tables.php file need to be modified to allow you to log in to Admin.

 

At or Around Line 16 add:

 

  define('TABLE_ADMINISTRATORS', 'administrators');

Link to comment
Share on other sites

Despite doing my best to try to see if I overlooked uploading or modifying any files, I still don't get any discounts. Yes, I can create coupons and add all the figures and totals, and I can enter a discount coupon code upon checkout. But, at the end, nothing. No discount, no error messages -- even when I type in a code that does not exist.

 

So, what gives? Are there any bug fixes that anyone knows about?

Link to comment
Share on other sites

turn on logging and store queries to a datafile which is in your own path (/home/yourname/tmp/coupon.log) something like that. then try checking out again once you are positive logging is happening. then where it fails, you can turn off logging, download the log file and read through it to find out what is happening step by step.

Link to comment
Share on other sites

This is the support thread for the Order Total contribution Discount Coupon Codes found here:

 

http://www.oscommerce.com/community/contributions,4269

 

KG,

 

I have installed your contribution, modified it to work with virtual products, but I need a slightly greater modification.

I was wondering how long would it take you to make an update to allow the use of multiple coupons on the same cart.

 

I imagine it would be adding the use of a delimiter in the coupon entry, reading that into an array, then running a loop for the count in the array.

 

I would also like to ad a coupon exclusion, so that certain coupons could not be combined while still allowing use of multiple coupons on a single cart.

 

I have many single use coupons that are fixed $ discounts on a single item. But I also have % discounts on real products that may be bought at the same time.

 

These coupons are not being recorded as being used, even after a coupon has been recorded in a completed sale.

 

 

ORDER shows this:

 

Products Model Tax Price (ex) Price (inc) Total (ex) Total (inc)

1 x 470 Crock Pot Recipes

- Download: Yes Zipped PDF 5.00% $0.99 $1.04 $0.99 $1.04

Tax not applied: -$0.00

Discount Coupon FREEDOWNLOAD applied: -$0.98

Sub-Total: $0.01

MD 5% tax + US Buyer remits taxes: $0.00

Total: $0.01

 

But

REPORT show this:

 

Code Discount Amount Global Number Available Number Used Global Number Available Remaining

2. FREEDOWNLOAD $0.98 1 0 1

 

 

I am still working on allowing skipping of payment method if total == $0.

 

Any help at all will be greatly appreciated.

 

 

~~~Tapuahk

Link to comment
Share on other sites

I am still working on allowing skipping of payment method if total == $0.

 

Any help at all will be greatly appreciated.

~~~Tapuahk

 

I got this fix, to sell free items simply change checkout_confirmation.php as follows:

 

find:

 

<?php
 if (isset($$payment->form_action_url)) {
   $form_action_url = $$payment->form_action_url;
 } else {
   $form_action_url = tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL');
 }

 

replace with:

<?php
// if order total is equal to zero redirect to checkout_process
  if ($order->info['total']<0.005) {
//            Too little to process payment for $0.0049 
           $form_action_url = tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL');
  } else {
//          They will have to pay 

 if (isset($$payment->form_action_url)) {
   $form_action_url = $$payment->form_action_url;
 } else {
   $form_action_url = tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL');
 }
}

Link to comment
Share on other sites

Still having problems with DCC recording usage...

 

Will work on multiple coupon fix over weekend, maybe the solution to lack of usage recording will present itself when I walk through code.

 

 

Sigh :(

 

~~~Tapuahk

 

 

KGT,

 

I think I should have the multiple coupon modification done in a week, but I'm slow at documenting what I do so I may not have it posted here in the same time frame.

Edited by tapuahk
Link to comment
Share on other sites

Debug is as follows:

<!-- Discount Coupons DEBUG
order Object
(
   [info] => Array
       (
           [order_status] => 4
           [currency] => USD
           [currency_value] => 1.00000000
           [payment_method] => PayPal Website Payments Standard
           [cc_type] => 
           [cc_owner] => 
           [cc_number] => 
           [cc_expires] => 
           [shipping_method] => 
           [shipping_cost] => 
           [subtotal] => 0
           [tax] => 0
           [tax_groups] => Array
               (
                   [MD 5% tax + US Buyer remits taxes] => 0
               )

           [comments] => 
           [total] => 0
       )

   [totals] => Array
       (
       )

   [products] => Array
       (
           [0] => Array
               (
                   [qty] => 1
                   [name] => How to Get the TRUTH Out of Anyone
                   [model] => PDF
                   [tax] => 5
                   [tax_description] => MD 5% tax + US Buyer remits taxes
                   [price] => 0.9900
                   [final_price] => 0.99
                   [weight] => 0.00
                   [id] => 112{1}1
                   [attributes] => Array
                       (
                           [0] => Array
                               (
                                   [option] => Download
                                   [value] => Yes
                                   [option_id] => 1
                                   [value_id] => 1
                                   [prefix] => +
                                   [price] => 0.0000
                               )

                       )

               )

       )

   [customer] => Array
       (
           [firstname] => Melissa
           [lastname] => Monroe
           [company] => 
           [street_address] => 
           [suburb] => 
           [city] => Cumberland
           [postcode] => 21502
           [state] => Maryland
           [zone_id] => 31
           [country] => Array
               (
                   [id] => 223
                   [title] => United States
                   [iso_code_2] => US
                   [iso_code_3] => USA
               )

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

   [delivery] => Array
       (
           [firstname] => Melissa
           [lastname] => Monroe
           [company] => 
           [street_address] => 
           [suburb] => 
           [city] => Cumberland
           [postcode] => 21502
           [state] => Maryland
           [zone_id] => 31
           [country] => Array
               (
                   [id] => 223
                   [title] => United States
                   [iso_code_2] => US
                   [iso_code_3] => USA
               )

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

   [content_type] => virtual
   [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 = 0
                           [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 = Display discounted tax in separate line
                           [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 112{1}1:  1.
                           [15] => INFO: Fixed discount applied to product 112{1}1:  -0.01.
                           [16] => INFO: Fixed adjustment for product 112{1}1: difference: 1 unadjusted applied_discount: -0.01
                           [17] => INFO: Product 112{1}1 passed exclusion check.  Discount 0.99 applied. (fixed)
                           [18] => INFO: Applied tax of 5 to: 0.99
                           [19] => INFO: Tax not applied to product 112{1}1: 0
                           [20] => INFO: Discount of 0.99 applied to product 112{1}1 ($0.99).
                           [21] => INFO: Calculating tax on 0.  Displayed price 0.
                       )

               )

           [coupon] => Array
               (
                   [coupons_id] => FREEDOWNLOAD
                   [coupons_description] => FREE EBOOK DOWNLOAD
                   [coupons_discount_amount] => 0.990000000000
                   [coupons_discount_type] => fixed
                   [coupons_date_start] => 
                   [coupons_date_end] => 
                   [coupons_max_use] => 1
                   [coupons_min_order] => 0.9900
                   [coupons_min_order_type] => price
                   [coupons_number_available] => 1
               )

           [applied_discount] => Array
               (
                   [MD 5% tax + US Buyer remits taxes] => 0.99
               )

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

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

                   [exclusions] => Array
                       (
                           [categories] => Array
                               (
                                   [0] => 38
                                   [1] => 41
                                   [2] => 42
                                   [3] => 43
                                   [4] => 44
                               )

                           [products] => Array
                               (
                                   [0] => 103
                                   [1] => 104
                                   [2] => 106
                                   [3] => 107
                                   [4] => 117
                                   [5] => 118
                                   [6] => 119
                                   [7] => 120
                                   [8] => 121
                                   [9] => 131
                                   [10] => 132
                               )

                           [manufacturers] => Array
                               (
                               )

                       )

               )

           [discount_tax] => Array
               (
                   [MD 5% tax + US Buyer remits taxes] => 0
               )

       )

   [billing] => Array
       (
           [firstname] => Melissa
           [lastname] => Monroe
           [company] => 
           [street_address] => 
           [suburb] => 
           [city] => Cumberland
           [postcode] => 21502
           [state] => Maryland
           [zone_id] => 31
           [country] => Array
               (
                   [id] => 223
                   [title] => United States
                   [iso_code_2] => US
                   [iso_code_3] => USA
               )

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

)

End Discount Coupons DEBUG-->

 

I don't see any problems, maybe your eyes can catch it...

 

Thanks in advance,

 

~~~Tapuahk

Link to comment
Share on other sites

Hi I just installed your plugin and its great! I can add, remove, and use coupons, but the "Cupom Code

 -X.XX" field in the confirmation page doesnt appear! When looking into the invoice, the coupon wasnt applied, but in the sql database its shown as used, so everything is working fine, but I cant get the coupon to discount an order ;/

 

Whats the matter?

Link to comment
Share on other sites

I am currently testing arround with this contribution and think, that it will fullfill my needs (good work!). However I am somewhat irritated, because the percentage discount seems to be wrong calculated. For ex. I have an article in my basket with an total order value of "149.90". I am giving .1 percent discount on it. However in the confirmation there is only a discount value of -12.60EUR. The discount module is order 0, the subtotal is 1. Shipping is added afterwards. So it look like he takes the wrong value. However, I select a fixed discount, everything is fine. Anyone a hint, what might be the problem? I am currently running out of ideas. Thanks in advise!

Link to comment
Share on other sites

Hi, just get the DCC to work, but after installing the subtotal without discount fix, my order's total doesnt change!

 

Ex:

Subtotal: 30.00

USPS: 8.00

Coupon: -10.00

Total: 38.00

 

If I remove the fix, everything starts to work fine again, but I really need to show the subtotal without discount first and changing the correspondent option in the plugin does nothing. Whats the matter?

Link to comment
Share on other sites

Hi, just get the DCC to work, but after installing the subtotal without discount fix, my order's total doesnt change!

 

Ex:

Subtotal: 30.00

USPS: 8.00

Coupon: -10.00

Total: 38.00

 

If I remove the fix, everything starts to work fine again, but I really need to show the subtotal without discount first and changing the correspondent option in the plugin does nothing. Whats the matter?

 

Hi, I am not sure on this, but it is an easy thing to try. Go into your Admin->Modules->Order Total and check to see how you have the order of the choices there. I remember I had to play around with mine when I had installed this contrib. I have mine as: Sub Total - 1, Tax - 2, Shipping - 3, Discount Coupon - 4 and Total - 5

 

Hope this helps!

Link to comment
Share on other sites

Thanks for your reply, but the problem was with my messy orders.php code :thumbsup:

btw, I just changed some code from the original plugin and now it has an option to add a kind of coupon that allows you to make a "free" order (like a gift voucher)

 

if anyone is interested please let me know

Link to comment
Share on other sites

I've been using this plug-in for over a year with no problems. No updates to the basic code of the site in a year, either. Recently, one of my users created a coupon, that looks like all the other five dollar discount coupons, and instead of applying a five dollar discount, it basically discounted everything in the basket.

 

The other five dollar coupon in the system, and the only other one active, works just fine. Has anyone seen anything like this?

 

Thanks for your help,

 

Ken

Link to comment
Share on other sites

Well, I think I squashed it. Not sure. It was really odd. The one that worked looked exactly the same in the database as the one that was very wrong. I deleted all coupons, as there were some test coupons created under version 2 still in there, except for the working one, recreated it, and it worked.

 

I really have no idea what was causing the problem, but it works now.

Link to comment
Share on other sites

Does this work with paypal express?

 

The trouble is, people on my site get to the payment page and click the orange paypal button and thus I dont know how to get the discount coupons onto their order. basically need a button on the payment page to add the coupon so then that gets passed to paypal express?

Link to comment
Share on other sites

I've installed the latest version of Discount Coupon Codes. I'm using the "Percentage Discount " Discount type method. It's seems to calculate the percentage based on products excluding VAT/TAX. Needed is to calculate the percentage based on products including VAT/TAX.

 

I probably have to change or add something to the ot_discount_coupon.php file in /httpdocs/includes/modules/order_total

 

Any suggestion?

Link to comment
Share on other sites

Can Anyone tell me why it might be that $display variable in discount_coupon.php will not pass to ot_discount_coupon.php? For some reason all discount is being calculated properly except no display of coupon code details.

Link to comment
Share on other sites

Hi, I really need a kind soul to assist here.

 

I have a big challenge here regarding to "customer exclusion". Admittedly, my use of discount coupon in my store is for refund purpose. So, when I need to make a refund to a customer, I give him/her a discount coupon. As by default, all newly-registered customers are not excluded from the "custerer exclusion" for a specific coupon (the coupon was created before the customers register), they can make use of this discount coupon if they know the coupon code. This poses a serious bug to the store as I will end up having many fraudulent coupon redemption.

 

Can anyone in this forum enlighten me how and where I should start to hack the code? If anyone did some mod for the purpose as above (to exclude those newly-registered customers to use the coupon), would you mind sharing the codes with us, or probably make it a contribution.

 

Thank you in advance.

 

Best Regards.

Link to comment
Share on other sites

Does anyone know how I can change the colour of the error messages?

 

Currently I get a red bar with the error text on it. Its not very easy to read. I have tried to change it in the following file

 

catalog/includes/languages/english.php

 

 

I have changed the following lines

//kgt - discount coupons
define('ENTRY_DISCOUNT_COUPON_ERROR', 'The coupon code you have entered is not valid.');
define('ENTRY_DISCOUNT_COUPON_AVAILABLE_ERROR', 'The coupon code you have entered is no longer valid.');
define('ENTRY_DISCOUNT_COUPON_USE_ERROR', 'Our records show that you have used this coupon %s time(s).  You may not use this code more than %s time(s).');
define('ENTRY_DISCOUNT_COUPON_MIN_PRICE_ERROR', 'The minimum order total for this coupon is %s');
define('ENTRY_DISCOUNT_COUPON_MIN_QUANTITY_ERROR', 'The minimum number of products required for this coupon is %s');
define('ENTRY_DISCOUNT_COUPON_EXCLUSION_ERROR', 'Some or all of the products in your cart are excluded.' );
define('ENTRY_DISCOUNT_COUPON', 'Coupon Code:');
define('ENTRY_DISCOUNT_COUPON_SHIPPING_CALC_ERROR', 'Your calculated shipping charges have changed.');
//end kgt - discount coupons

 

To

//kgt - discount coupons
define('ENTRY_DISCOUNT_COUPON_ERROR', '<font color="#FFFFFF">The coupon code you have entered is not valid</font>.');
define('ENTRY_DISCOUNT_COUPON_AVAILABLE_ERROR', '<font color="black">The coupon code you have entered is no longer valid</font>.');
define('ENTRY_DISCOUNT_COUPON_USE_ERROR', '<font color="#FFFFFF">Our records show that you have used this coupon %s time(s).  You may not use this code more than %s time(s) </font>.');
define('ENTRY_DISCOUNT_COUPON_MIN_PRICE_ERROR', '<font color="#FFFFFF">The minimum order total for this coupon is %s </font>');
define('ENTRY_DISCOUNT_COUPON_MIN_QUANTITY_ERROR', '<font color="#FFFFFF">The minimum number of products required for this coupon is %s </font>');
define('ENTRY_DISCOUNT_COUPON_EXCLUSION_ERROR', '<font color="#FFFFFF">Some or all of the products in your cart are excluded</font>.' );
define('ENTRY_DISCOUNT_COUPON', 'Coupon Code:');
define('ENTRY_DISCOUNT_COUPON_SHIPPING_CALC_ERROR', 'Your calculated shipping charges have changed.');
//end kgt - discount coupons

 

 

That doesnt seem to alter the colour of the txt so I guess it must coded in to the DCC files some where but not sure where.

Link to comment
Share on other sites

Its ok I figured out its in the stylsheet.css

 

If anyone else needs to know its under

TD.headerError {
 font-family: Tahoma, Verdana, Arial, sans-serif;
 font-size: 12px;
 background: #ff0000;
 color: #ffffff;
 font-weight : bold;
 text-align : center;

 

I changed the color to make it white

Link to comment
Share on other sites

Hello, I really tried to read all the 100 pages of this topic, but after 20 I gave up...

 

For this contribution, If a product is in any excluded category, it will be considered an excluded item. For example, Product A is in Category 1 and Category 2. Category 1 is an excluded category. Even if a customer sees Product A in Category 2 and adds it to his/her cart, the product will still be considered excluded because Category 1 is excluded.

 

Is it possible to invert this ?

Ex : Belgium is in BENELUX, EUROPE, WORLD

 

If I authorize BENELUX, system will accept coupons for belgium, even if EUROPE is excluded ...

 

???

 

Thanks to all those PRO finding all those answers ;)

Link to comment
Share on other sites

QUOTE(Kopite @ Nov 3 2007, 10:51 AM) *

Hi,

 

All seems to be working good except EXCLUSIONS.

 

None seem to be working.

 

I created a discounted shipping code for 1 product. I excluded all other manufacturers, categories and products.

 

But I can apply the code to all products.

 

Thanks.

 

the same thing happend to me.. i'm using RC2a with 3.31 version of DCC...

 

any help pls?

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