cyberma007 Posted December 31, 2006 Share Posted December 31, 2006 Hi Thanks for all the hard work that has been put out on this. I have 2 problems I got the latest code installed!. When i create a Discount and Set Max use 1 and Avaliable to 3 , Same customer can use the code 3 times insted for 1 time this is the code in discount_coupon.php function check_coupons_max_use() { global $customer_id; $check_use_query = tep_db_query($sql = "SELECT COUNT(*) AS cnt FROM ".TABLE_ORDERS." AS o INNER JOIN ".TABLE_DISCOUNT_COUPONS_TO_ORDERS." dc2o ON dc2o.orders_id=o.orders_id AND o.customers_id = '".(int)$customer_id."' AND dc2o.coupons_id='".tep_db_input( $this->code )."'"); $use = tep_db_fetch_array( $check_use_query ); //show error message if coupons_max_use is equal to the number of times this customer has used the code if( $this->coupon['coupons_max_use'] <= $use['cnt'] ) $this->error_message[] = sprintf( ENTRY_DISCOUNT_COUPON_USE_ERROR, $use['cnt'], $this->coupon['coupons_max_use'] ); //display the error message for number of times used } and also when amount on the cart is less than Max order and customer tries to checkout i get this Not Found The requested URL /checkout_payment.php/error_message/The+minimum+order+total+for+this+coupon+is+<span+class=currency_symbol>$</span>100.00<span+class=currency_symbol></span> was not found on this server. this is the code used, My header file is ok, it shows other error messasges just fine thanks for any help that can be provided function check_coupons_min_order() { global $order, $currencies; //if we display the subtotal without the discount applied, then just compare the subtotal to the minimum order if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'false' && $this->coupon['coupons_min_order'] > $order->info['subtotal'] ) { $this->error_message[] = sprintf( ENTRY_DISCOUNT_COUPON_MIN_ERROR, $currencies->format( $this->coupon['coupons_min_order'], true, $order->info['currency'], $order->info['currency_value'] ) ); //if we display the subtotal with the discount applied, then we need to compare the subtotal with the discount added back in to the minimum order } else if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'true' ) { $subtotal = $order->info['subtotal']; foreach( $order->info['applied_discount'] as $discount ) { $subtotal += $discount; } if( $this->coupon['coupons_min_order'] > $subtotal ) $this->error_message[] = sprintf( ENTRY_DISCOUNT_COUPON_MIN_ERROR, $currencies->format( $this->coupon['coupons_min_order'], true, $order->info['currency'], $order->info['currency_value'] ) ); } } Quote Link to comment Share on other sites More sharing options...
creanijn Posted December 31, 2006 Share Posted December 31, 2006 Hello, I have already installed the 1ste version of this contribution in August. I took the time to read part of this discussion, but 39 pages is a whole lot, so I'm posting a new message with my question. I was wondering if the following is possible: I have quite some products with a discount in my shop. Sometimes, I give customers a discount code to use when checking out. But in that case, they get a double discount, and I want to avoid that... Is this already part of the 2nd release of the contribution? I don't know if it's a lot of work to realise that, but I'm very eager to know! Thank you very much and I wish everyone the best for the new year 2007! Best regards, Vicky Quote Link to comment Share on other sites More sharing options...
kgt Posted January 2, 2007 Author Share Posted January 2, 2007 Hello, I have already installed the 1ste version of this contribution in August. I took the time to read part of this discussion, but 39 pages is a whole lot, so I'm posting a new message with my question. I was wondering if the following is possible: I have quite some products with a discount in my shop. Sometimes, I give customers a discount code to use when checking out. But in that case, they get a double discount, and I want to avoid that... Is this already part of the 2nd release of the contribution? I don't know if it's a lot of work to realise that, but I'm very eager to know! Thank you very much and I wish everyone the best for the new year 2007! Best regards, Vicky The newest version, which is being tested right now, will give you the ability to prevent products already on special from being discounted with a coupon. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
kgt Posted January 2, 2007 Author Share Posted January 2, 2007 Hi Thanks for all the hard work that has been put out on this. I have 2 problems I got the latest code installed!. When i create a Discount and Set Max use 1 and Avaliable to 3 , Same customer can use the code 3 times insted for 1 time this is the code in discount_coupon.php Are you using paypal ipn? If so, see the contribution page for a fix. If not, please check to see if there are entries in the discount_coupons_to_orders table for that used coupon. and also when amount on the cart is less than Max order and customer tries to checkout i get this Not Found The requested URL /checkout_payment.php/error_message/The+minimum+order+total+for+this+coupon+is+<span+class=currency_symbol>$</span>100.00<span+class=currency_symbol></span> was not found on this server. this is the code used, My header file is ok, it shows other error messasges just fine Probably because of the URL rewriting you're using and the slash in the span tag in the error message. If you manually change the URL to: /checkout_payment.php/error_message/The+minimum+order+total+for+this+coupon+is+$100.00 does it work? Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
kgt Posted January 2, 2007 Author Share Posted January 2, 2007 Anyone have a problem with the discount rates being a few percentage points lower than what is expected? E.g. - discount is 25%, but user gets onely 23% off. Can you give an example order confirmation page where this happens (include the item prices and quantities as they can make a difference)? Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
kgt Posted January 2, 2007 Author Share Posted January 2, 2007 I would be happy if I could change the Item/Product description passed to paypal from MyStoreName to MyStoreName Order no. #### Any idea how to do that? This is more of a paypal question. Try posting in the general questions forum. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
kgt Posted January 2, 2007 Author Share Posted January 2, 2007 Hello . I like you contribution and everything was smooth until we did a test order and hit the checkout_payment.php page which has the following errors? Could someone help me debug this tiny error. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/awardspl/public_html/awards/checkout_payment.php:2) in /home/awardspl/public_html/awards/includes/functions/sessions.php on line 97 Cart URL You have output occurring in awards/checkout_payment.php on line 2. I can't tell you how to fix it without seeing the code. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
kgt Posted January 2, 2007 Author Share Posted January 2, 2007 Hi kgt, I added the following code in checkout_payment.php to get the error messages work with STS 4.3: The error messages work now but i still get the error message also in the URL which seems weird... Any clues for that problem? Thanks for your help, Eric :D The message will display in the URL because that's how the error message is passed from page to page. It is normal (and required). Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
Dynatech Posted January 2, 2007 Share Posted January 2, 2007 The message will display in the URL because that's how the error message is passed from page to page. It is normal (and required). Hi kgt, Okay i understand, thank you! Cheers, Eric :) Quote Link to comment Share on other sites More sharing options...
kgt Posted January 2, 2007 Author Share Posted January 2, 2007 looks like our psychic friend KGT already had the answer...POST. :thumbsup: just added the code per that post to my header file, and the error messages seem to be working as intended. however, the error message looks like this: The minimum order total for this coupon is <span class=currency_symbol>$</span>5,000.00<span class=currency_symbol></span> not sure how to get rid of the <span> sections, so just changed the text to "The minimum order total for this coupon has not been met." would prefer to include the min value, if there's an easy fix. thanks. The span is there because the error message uses the currencies class to correctly display the currency symbol. If you only use one currency, you can change includes/languages/english.php to read: define('ENTRY_DISCOUNT_COUPON_MIN_ERROR', 'The minimum order total for this coupon is $%s'); Then edit includes/classes/discount_coupon.php. Change lines 54-67 to: function check_coupons_min_order() { global $order, $currencies; //if we display the subtotal without the discount applied, then just compare the subtotal to the minimum order if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'false' && $this->coupon['coupons_min_order'] > $order->info['subtotal'] ) { $this->error_message[] = sprintf( ENTRY_DISCOUNT_COUPON_MIN_ERROR.$order->info['subtotal'], number_format( $this->coupon['coupons_min_order'], 2 ) ); //if we display the subtotal with the discount applied, then we need to compare the subtotal with the discount added back in to the minimum order } else if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'true' ) { $subtotal = $order->info['subtotal']; foreach( $order->info['applied_discount'] as $discount ) { $subtotal += $discount; } if( $this->coupon['coupons_min_order'] > $subtotal ) $this->error_message[] = sprintf( ENTRY_DISCOUNT_COUPON_MIN_ERROR, number_format( $this->coupon['coupons_min_order'], 2 ) ); } } (Not tested) Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
kgt Posted January 2, 2007 Author Share Posted January 2, 2007 Have those who already installed this have the SQL script necessary to create the tables? Am I missing something? This has nothing to do with the SQL script or the tables. It's purely a code issue - you're missing the defines for the tables in includes/database_tables.php. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
creanijn Posted January 2, 2007 Share Posted January 2, 2007 The newest version, which is being tested right now, will give you the ability to prevent products already on special from being discounted with a coupon. Do you have any idea when the newest version will be published? Thank you very much for the information! best regards, Vicky Quote Link to comment Share on other sites More sharing options...
cyberma007 Posted January 3, 2007 Share Posted January 3, 2007 Thanks KGT This Worked great. You are the Best The span is there because the error message uses the currencies class to correctly display the currency symbol. If you only use one currency, you can change includes/languages/english.php to read: define('ENTRY_DISCOUNT_COUPON_MIN_ERROR', 'The minimum order total for this coupon is $%s'); Then edit includes/classes/discount_coupon.php. Change lines 54-67 to: function check_coupons_min_order() { global $order, $currencies; //if we display the subtotal without the discount applied, then just compare the subtotal to the minimum order if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'false' && $this->coupon['coupons_min_order'] > $order->info['subtotal'] ) { $this->error_message[] = sprintf( ENTRY_DISCOUNT_COUPON_MIN_ERROR.$order->info['subtotal'], number_format( $this->coupon['coupons_min_order'], 2 ) ); //if we display the subtotal with the discount applied, then we need to compare the subtotal with the discount added back in to the minimum order } else if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'true' ) { $subtotal = $order->info['subtotal']; foreach( $order->info['applied_discount'] as $discount ) { $subtotal += $discount; } if( $this->coupon['coupons_min_order'] > $subtotal ) $this->error_message[] = sprintf( ENTRY_DISCOUNT_COUPON_MIN_ERROR, number_format( $this->coupon['coupons_min_order'], 2 ) ); } } (Not tested) Quote Link to comment Share on other sites More sharing options...
cyberma007 Posted January 3, 2007 Share Posted January 3, 2007 Hi No I not using Paypal IPN, Yes i do see data in discount_coupons_to_orders it shows like this discount_coupons_to_orders_id coupons_id orders_id 18 123abc 0 17 123abc 0 16 123abc 0 And this was the coupon created for it coupons_id coupons_description coupons_discount_percent coupons_date_start coupons_date_end coupons_max_use coupons_min_order coupons_max_order coupons_number_available 123abc Returned Customer Discount 0.0500 2006-12-30 00:00:00 2007-01-05 00:00:00 2 100.0000 100.0000 3 I created a coupon Max use 2 and avaliable 3, customer was able to put in 3 orders throght with that coupon insted for 2 the tables data looks messed up when i pasted here, i hope it makes sens. Thanks Are you using paypal ipn? If so, see the contribution page for a fix. If not, please check to see if there are entries in the discount_coupons_to_orders table for that used coupon. Quote Link to comment Share on other sites More sharing options...
colinw Posted January 3, 2007 Share Posted January 3, 2007 Hi, Thanks for a great contribution, no problems at all. Works exactly as it should but is it possible to have it NOT discount the special offers? In other words can it ignore anything that is already discounted in the specials section. Sorry if this issue has already been delt with but couldn't find anything on it. Thanks again Quote Link to comment Share on other sites More sharing options...
colinw Posted January 3, 2007 Share Posted January 3, 2007 Hi, Thanks great contribution works as it should but is there a way to NOT apply the discount to the specials section? Quote Link to comment Share on other sites More sharing options...
newtech Posted January 3, 2007 Share Posted January 3, 2007 The customers order report calculates the total by looking through all the customer's orders and adding up the prices of each item in the order, multiplied by the number of items. It never looks at the actual order subtotal, which is used in order calculation. You can fix this by changing it to calculate the totals based off of the subtotals in the orders_total table. I have not been able to find anybody on other forums to come up with the script to do the fix. Anybody here? Quote Link to comment Share on other sites More sharing options...
kgt Posted January 3, 2007 Author Share Posted January 3, 2007 Hi, Thanks great contribution works as it should but is there a way to NOT apply the discount to the specials section? This question has already been answered in this thread. The answer is not at this time, unless you change the code. The new version will allow you to exclude specials. It is in testing now. If you want it sooner, volunteer to test - I need more people to test before it's ready. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
kgt Posted January 3, 2007 Author Share Posted January 3, 2007 HiNo I not using Paypal IPN, Yes i do see data in discount_coupons_to_orders it shows like this CODE discount_coupons_to_orders_id coupons_id orders_id 18 123abc 0 17 123abc 0 16 123abc 0 Your order ids are not getting saved, so it's impossible to relate a coupon to an order and therefor impossible to relate it to a customer. Post the code you have for checkout_process.php. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
kgt Posted January 3, 2007 Author Share Posted January 3, 2007 Do you have any idea when the newest version will be published?Thank you very much for the information! best regards, Vicky Nothing more specific than "sometime soon." If you want it sooner rather than later, please PM or email me to help test it. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
kgt Posted January 3, 2007 Author Share Posted January 3, 2007 I have not been able to find anybody on other forums to come up with the script to do the fix. Anybody here? Replace line 60 in admin/stats_customers.php with this: $customers_query_raw = "select c.customers_firstname, c.customers_lastname, sum(ot.value) as ordersum from " . TABLE_CUSTOMERS . " c, " . TABLE_ORDERS_TOTAL . " ot, " . TABLE_ORDERS . " o where c.customers_id = o.customers_id and o.orders_id = ot.orders_id and ot.class='ot_total' group by c.customers_firstname, c.customers_lastname order by ordersum DESC"; Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
TracyS Posted January 3, 2007 Share Posted January 3, 2007 First I'd like to say THANK YOU for an Awesome Contribution!! :thumbsup: I have Discount Coupon Code 2.1 and Reports installed and running as it should! (which is something I've only had with a few contributions *before* posting to their forum). ;) I do have two questions though: 1. - As you can tell in my signature line I have a heavily modified store :blush: I see that the 2.1 version of DCC is supposed to be able to avoid giving a customer Free Shipping on an order sub-total that was calculated before the discount. But, I have the "Free Shipping with Minimum Amount" contribution installed (as I needed to specify a zone). Also - I have table rate setup for shipping only in the zone we have the free shipping option. So what happens (in a nutshell) is - if it's a retail customer the FSWMA contrib. will give them free shipping on orders of $150 or more. If it's a wholesale customer the FSWMA contrib. won't do anything and the table rate automatically puts the shipping cost at $0 on orders over $200. I'm not sure where or how I will need to tweak the DCC code or the FSWMA or Table Rate code to be able to make sure we don't offer free shipping when the subtotal *after* the discount is applied is less than the minimum order amount needed to qualify for free shipping. Do you have any tips or pointers on this? Has anyone else modified their DCC for this? I am more than happy to post or email any code you need to look at :) 2. - How is the "Not applying the discount to Specials" project going? I did try the recommended bits of code in this thread - but they didn't work. I am willing to help you test - but I'm no programmer - I'm still learning PHP myself and this is my first ever osC powered store so I'm not sure if I'd be much help for you :( At least this project looks like an update that is much anticipated by many people, and this forum appears to have regular discussions - so I do have faith that an update will be coming - just curious if there's any idea on the timeframe yet :thumbsup: Quote ~Tracy Link to comment Share on other sites More sharing options...
newtech Posted January 3, 2007 Share Posted January 3, 2007 Here is what I wanted: The customers order report calculates the total by looking through all the customer's orders and adding up the prices of each item in the order, multiplied by the number of items. It never looks at the actual order subtotal, which is used in order calculation. You can fix this by changing it to calculate the totals based off of the subtotals in the orders_total table. So I wanted the subtotal to be entered in the customers total report. When I do the following: Replace line 60 in admin/stats_customers.php with this: $customers_query_raw = "select c.customers_firstname, c.customers_lastname, sum(ot.value) as ordersum from " . TABLE_CUSTOMERS . " c, " . TABLE_ORDERS_TOTAL . " ot, " . TABLE_ORDERS . " o where c.customers_id = o.customers_id and o.orders_id = ot.orders_id and ot.class='ot_total' group by c.customers_firstname, c.customers_lastname order by ordersum DESC"; the customers total report is showing the grand total including shipping and taxes, minus the discount. Again what we want in the customers total report is the subtotal sales (sales minus taxes, shipping, and the discount). Quote Link to comment Share on other sites More sharing options...
KCL Posted January 4, 2007 Share Posted January 4, 2007 Great Contribution! I have install the latest version and try it. It seems not working with the table rate shipping. Can anyone point me to the right direction? Quote Link to comment Share on other sites More sharing options...
TracyS Posted January 4, 2007 Share Posted January 4, 2007 Great Contribution! I have install the latest version and try it. It seems not working with the table rate shipping. Can anyone point me to the right direction? I just installed it yesterday, and I'm running both Table Rate and USPS - and it seems to be working fine. I just need to learn how to tweak it for the types of free shipping I have. What is yours doing? Are you getting any error messages? What is your "Sort Order" in Admin->Modules->Order Total ? Quote ~Tracy Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.