kgt Posted August 30, 2006 Author Share Posted August 30, 2006 Good morning, I like this contribution, but... since I'm based in Europe the invoices have to mention all products, costs and promotions excl. vat and have the vat added to the final total. But the Discount Coupon Codes contribution already includes VAT, is there any way to get the amount without VAT incorporated ? Friendly Greetings, Tim, Example: (ands it even confusing for our customers) Item1: 9,92EUR (excl) Discount Coupon x applied: -2,00EUR (incl) VAT 21%: 1,74EUR (vat) Sub-total: 10,00EUR (incl) Shipping: 6,54EUR (incl) Total: 16,54EUR (incl) Minor issue: I use multiple languages and in each language it says "Discount Coupon x applied" Major issue: why is the error reporting in the header ? VAT should only be incorporated if you have display prices with tax in Configuration > My Store set to true. Otherwise it should NOT be adding tax to the discount amount. Your numbers don't seem to be adding up quite right anyways. Email or PM me and I'll help you get it working like it's supposed to. Multiple languages: an oversight with the changes to 2.0. If you're not using 2.0, then you only need to provide the translations. I'll assume you're using 2.0, and that you've made ot_discount_coupon.php files for each language in includes/languages/language/modules/order_total/. If so, you should be able to do a one-line fix. In includes/modules/order_total/ot_discount_coupons.php line 49 replace: $display = MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_FORMAT; with $display = MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY; The constant MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY comes from the language files. You just need to edit those so that they read define('MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY', 'Discount Coupon applied'); for each language you use. (You can then use any of the other variables like [percent_discount] to format your line how you want it.) Error reporting in the header: This is the standard method OSCommerce uses. I didn't add any error reporting, just chose to use what is present in a stock OSC store. If you need something else, you shouldn't find it too terribly complicated to have the errors display elsewhere. You just need a line that checks for a variable called error_message and display it if it's present. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
DarrenWu Posted August 30, 2006 Share Posted August 30, 2006 That's what the max_order field is for. If you set a max_order, it will only apply the discount to that amount. So you can set a limit to the maximum discount people can recieve. This is used for fixed discounts, but it can be used for percentage discounts as well. There is a link to the manual at the top right of the coupons admin screen. I see, i was thinking about the wrong way. Thanks Quote Link to comment Share on other sites More sharing options...
windfjf Posted August 30, 2006 Share Posted August 30, 2006 Use the same solution. Comment out the require_once line in includes/modules/order_total/ot_discount_coupon.php. thanks, I think there's the other bug in /admin/coupons.php about 194: "if( !empty( $cInfo->coupons_max_order ) && !empty( $cInfo->coupons_min_order ) && $cInfo->coupons_max_order == $cInfo->coupons_min_order ) { $fixed_discount = $cInfo->coupons_discount_percent * $cInfo->coupons_max_order; }" It's for get $fixed_discount . when : I use Percent Discount:0.1 , and Min Order=Max Order =20 then: Desired Fixed Discount=2 (It's wrong,should be nothing) so : I want to use "Percent Discount", but actually I ues Desired Fixed Discount when Min Order=Max Order . sorry my English. Quote Link to comment Share on other sites More sharing options...
windfjf Posted August 30, 2006 Share Posted August 30, 2006 perhaps needs add a variable in table osc_discount_coupons distinguish "Desired Fixed Discount " from " Percent Discount". discount_method: =0 -- Percent Discount =1 -- Desired Fixed Discount and add a exclusive opt. in /admin/coupons.php when insert a new Discount Coupons. Quote Link to comment Share on other sites More sharing options...
kgt Posted August 30, 2006 Author Share Posted August 30, 2006 thanks, I think there's the other bug in /admin/coupons.php about 194: "if( !empty( $cInfo->coupons_max_order ) && !empty( $cInfo->coupons_min_order ) && $cInfo->coupons_max_order == $cInfo->coupons_min_order ) { $fixed_discount = $cInfo->coupons_discount_percent * $cInfo->coupons_max_order; }" It's for get $fixed_discount . when : I use Percent Discount:0.1 , and Min Order=Max Order =20 then: Desired Fixed Discount=2 (It's wrong,should be nothing) so : I want to use "Percent Discount", but actually I ues Desired Fixed Discount when Min Order=Max Order . sorry my English. If you have a min_order and max_order set, with a discount of 10%, then this will always be equal to $2.00. It's not going to do both a 10% discount and a $2 discount. It will do the 10% discount, which in this case is the same as doing a $2 discount. The "Fixed Discount" field in coupons.php is for convenience only. It's showing you the fixed value of your discount if you have min_order=max_order. The actual stored value of the discount in the database is as a percentage. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
windfjf Posted August 30, 2006 Share Posted August 30, 2006 If you have a min_order and max_order set, with a discount of 10%, then this will always be equal to $2.00. It's not going to do both a 10% discount and a $2 discount. It will do the 10% discount, which in this case is the same as doing a $2 discount. The "Fixed Discount" field in coupons.php is for convenience only. It's showing you the fixed value of your discount if you have min_order=max_order. The actual stored value of the discount in the database is as a percentage. Thank you very much. I see now.The "Fixed Discount" field in coupons.php is for convenience only. otherwise, Do you have plan improve this module allows to set discount for specifically products or categories ? Quote Link to comment Share on other sites More sharing options...
watchdog Posted August 31, 2006 Share Posted August 31, 2006 VAT should only be incorporated if you have display prices with tax in Configuration > My Store set to true. Otherwise it should NOT be adding tax to the discount amount. Your numbers don't seem to be adding up quite right anyways. Email or PM me and I'll help you get it working like it's supposed to.Multiple languages: an oversight with the changes to 2.0. If you're not using 2.0, then you only need to provide the translations. I'll assume you're using 2.0, and that you've made ot_discount_coupon.php files for each language in includes/languages/language/modules/order_total/. If so, you should be able to do a one-line fix. In includes/modules/order_total/ot_discount_coupons.php line 49 replace: $display = MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_FORMAT; with $display = MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY; The constant MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY comes from the language files. You just need to edit those so that they read define('MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY', 'Discount Coupon applied'); for each language you use. (You can then use any of the other variables like [percent_discount] to format your line how you want it.)Error reporting in the header: This is the standard method OSCommerce uses. I didn't add any error reporting, just chose to use what is present in a stock OSC store. If you need something else, you shouldn't find it too terribly complicated to have the errors display elsewhere. You just need a line that checks for a variable called error_message and display it if it's present. Thank you for the quick reply, Well, the store displays all prices including VAT, so it's pretty normal that the discount includes vat as well.However, the order confirmations/invoices are all excluding vat, this is not default oscommerce behaviour but this is mandatory in Europe. The order confirmation/invoice pages have been altered to display excluding vat, but since this is an order total module I cannot change the vat behaviour. > Discount Coupon Codes 2.0 + the 2.0 bugfix For now I have uninstalled it, but I will be watching the contribution for the near future. Thanks for all your efforts !!Tim (from Belgium), Quote Link to comment Share on other sites More sharing options...
watchdog Posted August 31, 2006 Share Posted August 31, 2006 ps: this is the correct summary (without DCC20): Item1: 9,92EUR Item2: 9,92EUR VAT 21%: 4,17EUR Sub-total (Incl. VAT): 24,00EUR Shipping (free of VAT): 6,54EUR Total (Incl. VAT): 30,54EUR yes, to be ideal there should be another sub-total excl. vat but it's compliant now and I simply don't master php in order to duplicate and change ot_subtotal.php Quote Link to comment Share on other sites More sharing options...
wenmian Posted September 1, 2006 Share Posted September 1, 2006 The discount coupon is truly was truly not coded to apply any discount to shipping. It was meant to apply it to the subtotal only, so that tax would be correctly calculated and shipping would not be affected (most stores don't include shipping when figuring a discount). You can do this, but it will probably not be very easy. It sounds to me like you're wanting more of a voucher, which is a form of payment, rather than a discount. Have you looked as CCGV? Yea, you're right. Indeed i'm trying to find a solution to combine vouchers + coupons into a single package. I did look at CCGV, but figured my oscommerce is too much modded to install CCGV easily. I look at the number of files that have to be updated and kinda give up. Anyway, glad to say I'm slowly achieving what I intended. The only easy way I could include shipping is retroactive comparison, or, to do most of the computations in ot_shopping.php. I know its not the ideal file to work with, but thats the only file where all the $order->info['***'] have all the final values, with shipping tax added and all. I'm also trying to achieve a way to bypass payment module if the $order->info['total'] <= 0, cos it doesnt really make sense to collect credit card details for $0 payments, besides, and possibly can save on credit card processing cost as well. I've been getting some success. Quote Link to comment Share on other sites More sharing options...
wenmian Posted September 1, 2006 Share Posted September 1, 2006 I think I spotted a potential fatal error....let me know if you get the same thing because the error might be because of the modifications i have made. When entering the coupon code into the code text box on the checkout_payment screen, key in a random code including a '\' (try it again with a '/') as well. Let me know what you guys got as a response. I got a fatal error for the SQL command to the mysql database. Let me know, thanks! Quote Link to comment Share on other sites More sharing options...
theornamentqueen Posted September 1, 2006 Share Posted September 1, 2006 Excellent! Thanks so much for such a clear and concise contribution! It is wonderful and just what I needed! Installation was a breeze, (well a breeze after I quit making a really stupid error, lol!) and the manual is first rate! I am working on the last bits of config, then my store will be ready to go live, hopefully by mid Sept. Thanks again....... I am one happy camper tonight! :D Linda Quote Link to comment Share on other sites More sharing options...
kgt Posted September 1, 2006 Author Share Posted September 1, 2006 I think I spotted a potential fatal error....let me know if you get the same thing because the error might be because of the modifications i have made.When entering the coupon code into the code text box on the checkout_payment screen, key in a random code including a '\' (try it again with a '/') as well. Let me know what you guys got as a response. I got a fatal error for the SQL command to the mysql database. Let me know, thanks! This is not created by you. Line 43 in includes/classes/discount_coupon.php should read WHERE coupons_id = '" . tep_db_input( $this->code ) . "' and NOT WHERE coupons_id = '" . tep_db_prepare_input( $this->code ) . "' Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
leegt5 Posted September 2, 2006 Share Posted September 2, 2006 When I log out as one customer and log in as another on the same computer and go to order a product where I would enter the coupon code its already there... Is there anyway so that it can be made so I have to re-enter it ?? Quote Link to comment Share on other sites More sharing options...
wenmian Posted September 3, 2006 Share Posted September 3, 2006 (edited) Kgt, I have a solution for this problem....don't round off until the ot_total.php module. meaning removing tep_round from both tep_calculate_tax() and tep_add_tax() functions in functions/general.php. And to make sure that what you pass to the payment gatewate is in the correct decimal places, replace in ot_total.php function process() { ....... 'value' => $order->info['total']); } with function process() { ....... 'value' => number_format($order->info['total']),2); } kgt, this should possibly solve any discrepancy caused by rounding off too early in the calculation. But am I right in assuming that 'value' is the final number that's being passed to the payment gateway? Please advise, thanks! Accuracy for taxation is actually why it is possible that the discount amount is slightly off. To ensure that the discount is always an exact amount requires that you subtract the tax "saved" from the discount from the order tax. Because of rounding (rounding when tax was calculated for the display and rounding again after the discounted tax amount is subtracted) the tax can be incorrect by one or two cents. I leaned towards accurate tax calculation rather than accurate discount amount. I'd rather have my $5.00 discount display as the true rounded discount amount than have my tax calculation be slightly off. Since ensuring an accurate discount amount requires that you subtract that amount after the other order totals have been calculated (and rounded), other contributions can guarantee an accurate discount amount, but probably cannot guarantee accurate tax unless they completely recalculate the order totals. It's just a fact of what happens when rounding is involved. Edited September 3, 2006 by wenmian Quote Link to comment Share on other sites More sharing options...
wenmian Posted September 3, 2006 Share Posted September 3, 2006 yes, thats a potential security problem. hmmm...i had tot that the coupon only existed in the particular session. When I log out as one customer and log in as another on the same computer and go to order a product where I would enter the coupon code its already there... Is there anyway so that it can be made so I have to re-enter it ?? Quote Link to comment Share on other sites More sharing options...
dawnblue Posted September 3, 2006 Share Posted September 3, 2006 I posted this in the wrong place yesterday. I'm sorry: Hi. I am new and this is the first time I am installing a contribution. I just started uploading stuff to my store and wanted to be able to offer coupons to entice buyers. I have followed all the instructions and read the frequent problems file, but I am getting the error below. I have double checked and all the files that I needed to add to the site were added and are in their proper places in the directory. Also, I can see the coupon tables in the phpMyAdmin but am still getting this error. I am racking my brain and wanted to offer this tomorrow (sunday), but I don't see that happening right now. Any help is greatly appreciated. Users put things into their carts and then, when they enter a coupon code, this is the error that is generated. Warning: main(/mnt/w0705/d23/s12/b025cbb6/www/disney/nfoscomm/catalogincludes/classes/discount_coupon.php): failed to open stream: No such file or directory in /mnt/w0705/d23/s12/b025cbb6/www/disney/nfoscomm/catalog/includes/modules/order_total/ot_discount_coupon.php on line 13 Fatal error: main(): Failed opening required '/mnt/w0705/d23/s12/b025cbb6/www/disney/nfoscomm/catalogincludes/classes/discount_coupon.php' (include_path='.:/usr/local/nf/lib/php') in /mnt/w0705/d23/s12/b025cbb6/www/disney/nfoscomm/catalog/includes/modules/order_total/ot_discount_coupon.php on line 13 Thanks! Alicia Quote Link to comment Share on other sites More sharing options...
dawnblue Posted September 5, 2006 Share Posted September 5, 2006 Can anyone help me with the above request? I can't figure out where the problem is. Quote Link to comment Share on other sites More sharing options...
kgt Posted September 5, 2006 Author Share Posted September 5, 2006 When I log out as one customer and log in as another on the same computer and go to order a product where I would enter the coupon code its already there... Is there anyway so that it can be made so I have to re-enter it ?? Your browser is remembering the value you filled in that field before. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
kgt Posted September 5, 2006 Author Share Posted September 5, 2006 Warning: main(/mnt/w0705/d23/s12/b025cbb6/www/disney/nfoscomm/catalogincludes/classes/discount_coupon.php): failed to open stream: No such file or directory in /mnt/w0705/d23/s12/b025cbb6/www/disney/nfoscomm/catalog/includes/modules/order_total/ot_discount_coupon.php on line 13 Fatal error: main(): Failed opening required '/mnt/w0705/d23/s12/b025cbb6/www/disney/nfoscomm/catalogincludes/classes/discount_coupon.php' (include_path='.:/usr/local/nf/lib/php') in /mnt/w0705/d23/s12/b025cbb6/www/disney/nfoscomm/catalog/includes/modules/order_total/ot_discount_coupon.php on line 13 includes/configure.php. DIR_FS_CATALOG should have an ending slash. You wouldn't notice this resulting in an error in most cases because OSC does not use this constant all that often. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
kgt Posted September 5, 2006 Author Share Posted September 5, 2006 Kgt, I have a solution for this problem....don't round off until the ot_total.php module. meaning removing tep_round from both tep_calculate_tax() and tep_add_tax() functions in functions/general.php. And to make sure that what you pass to the payment gatewate is in the correct decimal places, replace in ot_total.php function process() { ....... 'value' => $order->info['total']); } with function process() { ....... 'value' => number_format($order->info['total']),2); } kgt, this should possibly solve any discrepancy caused by rounding off too early in the calculation. But am I right in assuming that 'value' is the final number that's being passed to the payment gateway? Please advise, thanks! Removing the tep_round() function from the tax functions, etc will solve the rounding problem, but you'll also break several other OSC pages including the product_info and any other page which uses the tep_round function indirectly via either of those functions. This really requires re-writing quite a bit to ensure rounding happens, including changing every single order total module. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
dawnblue Posted September 5, 2006 Share Posted September 5, 2006 includes/configure.php. DIR_FS_CATALOG should have an ending slash. You wouldn't notice this resulting in an error in most cases because OSC does not use this constant all that often. Ok - that value appears three times: define('DIR_FS_CATALOG', dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME'])); define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG. 'download/'); define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG. 'pub/'); Where do I put the ending slash? I'm sorry - I'm really new at this and do not know anything about php - this is all new to me. However, this is the only configure file I have and it was in catalog/includes - is that the right file? Quote Link to comment Share on other sites More sharing options...
kgt Posted September 5, 2006 Author Share Posted September 5, 2006 Ok - that value appears three times: define('DIR_FS_CATALOG', dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME'])); define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG. 'download/'); define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG. 'pub/'); Where do I put the ending slash? I'm sorry - I'm really new at this and do not know anything about php - this is all new to me. However, this is the only configure file I have and it was in catalog/includes - is that the right file? The part where it is actually defined is the first statement. The other statements are simply using the defined constant DIR_FS_CATALOG. You are missing the trailing slash. define('DIR_FS_CATALOG', dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']).'/'); Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
wenmian Posted September 5, 2006 Share Posted September 5, 2006 Hi, I'm also having this problem. Is there a way to prevent the code from being stored by the browser on the server side? Ideally it should be like the shopping cart. a second person logging in using the same computer does not see the shopping cart of the first person. Is tep_register_session the cause of this problem? Your browser is remembering the value you filled in that field before. Quote Link to comment Share on other sites More sharing options...
dawnblue Posted September 5, 2006 Share Posted September 5, 2006 The part where it is actually defined is the first statement. The other statements are simply using the defined constant DIR_FS_CATALOG. You are missing the trailing slash. define('DIR_FS_CATALOG', dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']).'/'); Thanks! That fixed it - but now I am getting this error at the top of the page: I am able to write to the configuration file: /mnt/w0705/d23/s12/b025cbb6/www/disney/nfoscomm/catalog/includes/configure.php. This is a potential security risk - please set the right user permissions on this file. It is still allowing checkout, etc. All I did was change that code. How do I fix that? Quote Link to comment Share on other sites More sharing options...
kgt Posted September 5, 2006 Author Share Posted September 5, 2006 Thanks! That fixed it - but now I am getting this error at the top of the page:I am able to write to the configuration file: /mnt/w0705/d23/s12/b025cbb6/www/disney/nfoscomm/catalog/includes/configure.php. This is a potential security risk - please set the right user permissions on this file. It is still allowing checkout, etc. All I did was change that code. How do I fix that? You should find many posts on this topic. It has to do with permissions on your site: http://www.google.com/search?hl=en&q=I...G=Google+Search Quote Contributions Discount Coupon Codes Donations 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.