[add-on] Discount Code (support)
#21
Posted 06 October 2010 - 06:22 AM
is it possible that you einbaust in the module nor the new customers will automatically receive discounts? or there is a discount code discount allows new customers only? or the first time the customer order
Thanks
Marvin
#22
Posted 06 October 2010 - 06:47 PM
My Issue: I installed everything, followed the directions perfectly, checked 4 times everything. I can even create coupons but when you checkout, there is nowhere to enter the discount code. I am assuming that the reason is because in the directions, it asks you to go to Modules > Order Total > Discount Coupons, but there is no Discount Coupons option in the Order Total area.
Any help with this would be greatly appreciated.
Thanks in Advance,
Simon
#23
Posted 06 October 2010 - 07:23 PM
Tesoro Design, on 06 October 2010 - 06:47 PM, said:
My Issue: I installed everything, followed the directions perfectly, checked 4 times everything. I can even create coupons but when you checkout, there is nowhere to enter the discount code. I am assuming that the reason is because in the directions, it asks you to go to Modules > Order Total > Discount Coupons, but there is no Discount Coupons option in the Order Total area.
Any help with this would be greatly appreciated.
Thanks in Advance,
Simon
My first thought would be to check to make sure the file:
.../catalog/includes/modules/ot_discount.php
uploaded correctly. If it is missing or got fouled during upload I think it would cause that effect. And if it didn't, I would check the other files that get uploaded to make sure they are ok while you are at it.
Second possibility - make sure you are looking for the right thing in the admin panel. If it is the "Discount Code" contrib that you installed and not the "Discount Coupon" one, then when you go to modules>order total in the admin panel, one of the items on the main part of the screen should be "Discount Code". Select it by clicking once on it. After the page reloads, click the "Install" button. After that completes, set the sort order.
If you installed the "Discount Coupon" contrib, that is a whole other bear and different support thread.
Rule #2: Make sure there are no exceptions to Rule #1.
#24
Posted 06 October 2010 - 07:49 PM
move_man, on 06 October 2010 - 06:22 AM, said:
is it possible that you einbaust in the module nor the new customers will automatically receive discounts? or there is a discount code discount allows new customers only? or the first time the customer order
Thanks
Marvin
Doesn't look like there is feature like that. But here is how I would approach it:
- Use the new version from the author's website mentioned a few posts above. It has the added feature of letting you limit the number of times per customer it can be used, for example one time per customer.
- Set up a discount code for use as a new customer discount.
- Add the new customer discount code and a sentence or two of explanation to the new account setup page. Either make the code real easy to remember or else encourage them to write it down. My way would be to make it real easy since the customer can only use it once anyway.
Rule #2: Make sure there are no exceptions to Rule #1.
#25
Posted 06 October 2010 - 08:53 PM
GraphicsGuy, on 06 October 2010 - 07:23 PM, said:
.../catalog/includes/modules/ot_discount.php
uploaded correctly. If it is missing or got fouled during upload I think it would cause that effect. And if it didn't, I would check the other files that get uploaded to make sure they are ok while you are at it.
Second possibility - make sure you are looking for the right thing in the admin panel. If it is the "Discount Code" contrib that you installed and not the "Discount Coupon" one, then when you go to modules>order total in the admin panel, one of the items on the main part of the screen should be "Discount Code". Select it by clicking once on it. After the page reloads, click the "Install" button. After that completes, set the sort order.
If you installed the "Discount Coupon" contrib, that is a whole other bear and different support thread.
I did do the Discount Coupons, is there another thread for that here?
#27
Posted 07 October 2010 - 12:39 AM
Discount Code: http://addons.oscommerce.com/info/7397
That is the contrib that this support thread is about although the author of it doesn't seem to be participating (although as someone noted a few posts up, they have continued refining it and a newer version can be found on their site at http://high-quality-...oscommerce.html .
Discount Coupon Codes: http://addons.oscommerce.com/info/4269
The support thread is here: http://forums.oscomm...t-coupon-codes/
Discount Coupons: http://addons.oscommerce.com/info/300
There doesn't appear to be a support thread. This is a very old contrib (2002) and requires the Credit Class Gift Voucher (CCGV) contrib to be installed first. In 2008 the CCGV contrib absorbed the Discount Coupons contrib, thereby obsoleting this one. - http://addons.oscommerce.com/info/5743 and the support thread is http://forums.oscomm.../page__hl__CCGV
Easy Coupon: http://addons.oscommerce.com/info/4213
The support thread is here: http://forums.oscomm..._Easy%20Coupons
Coupons by Ingo: http://addons.oscommerce.com/info/4148
The support thread is here: http://forums.oscomm...showtopic=41151 (on the German forum)
There are various threads discussing various issues:
- http://forums.oscomm...lem-with-ie-8-0
- http://forums.oscomm...coupons-by-ingo
- http://forums.oscomm...coupons-by-ingo
Edited by GraphicsGuy, 07 October 2010 - 12:40 AM.
Rule #2: Make sure there are no exceptions to Rule #1.
#28
Posted 08 October 2010 - 04:46 AM
kdupuis, on 12 May 2010 - 08:10 PM, said:
I downloaded the Discount Code contribution and really like it. There is one problem with calculating taxes.
When I have a discount code set up for 10% on a category. It does not calculate the tax portion properly.
Example:
Subtotal: $590.00
Discount: $59.00
5% Tax: $29.50
Total: $560.50
The tax amount should be 26.55 and the Total should be $557.55
Hey everyone,
I had this same issue and it seemed to be with this perticular line of code:
ot_discount.php line 61 (accordinly to 2.4 release)
$tax_discount[$order->products[$i]['tax_description']] += $products_discount * $order->products[$i]['tax'] / 100;
This line of code kept spitting out a warning something about illigal blah blah.. (forgot the exact error)
After using a bunch of print_r statements, I noticed that the array ($tax_discount) was actually empty.
so i updated the above line of code into the following and it worked for me!
ot_discount.php
foreach($order->products[$i]['tax_description'] as $key123 => $value123){
$tax_discount[$key123] += $products_discount * $order->products[$i]['tax'] / 100;
}
Not sure if this was the best and most efficient way, but it worked for me. If anyone has a better example, please feel free to show!
#29
Posted 15 October 2010 - 08:39 PM
Have installed this contribution, was easy to do. But run into a problem.
How do i use percentages in stead of a fixed price like 1 euro, i want to enter 5 or 10 % but when i do that and add a category i'm getting an error..
Greetings, Dj Viper
#30
Posted 16 October 2010 - 12:14 AM
Dj-Viper, on 15 October 2010 - 08:39 PM, said:
Have installed this contribution, was easy to do. But run into a problem.
How do i use percentages in stead of a fixed price like 1 euro, i want to enter 5 or 10 % but when i do that and add a category i'm getting an error..
Greetings, Dj Viper
Yeah, the contrib says you can use percentages, but I couldn't get it to accept them either. I didn't get any error messages, it just didn't apply any discount when I entered a percentage discount. I don't know if that has been fixed in the new releases on the authors web site since I haven't upgraded it yet on my site.
Rule #2: Make sure there are no exceptions to Rule #1.
#31
Posted 16 October 2010 - 01:44 PM
GraphicsGuy, on 16 October 2010 - 12:14 AM, said:
I have the newest version from the authors website (v2.5 from http://high-quality-php-coding.com/discount_code_module_for_oscommerce.html - you have to install the updates, there's no full package.).
The percentages work correctly on mine. I haven't used any previous version (I went straight to v2.5) so I would conclude that this issue has been fixed!
#32
Posted 21 October 2010 - 04:29 PM
frst of all I have to say that this is really a great contribution. I am using it on two different osCommerce installations and it is working great.
On one of my osCmmerce webistes I have installed this Contrib with version 2.5 - and it is simply working perfectly there. The server for this page uses PHP 4.4.9 and MySQL 4.1.22
On my other osCmmerce webiste (which uses MySQL 4.0.25), I have discovered a problem with version 2.5 of this Contrib though - propably due to the MYSQL version on this server, which I unfortunately can´t change though, as the domain is hosted on a shared server and the hosting company won´t do any changes to it.
I have been able to install the updates of the "Discount Codes" Contrib up to version 2.4 ... and it works properly up to that version ... but when I do the update towards version 2.5, there occurs a TEP STOP erroe in the checkout_confirmation.php and the customers can´t complete their order. As version 2.5 includes some nice features such as unlimited usages of discount codes by a customer or including the discount code to the order info, I would like to get version 2.5 running on that server as well.
The TEP STOP error I receive in the checkout_confirmation.php with version 2.5 contains the following error message:
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 'select count(*) as total from discount_codes dc, customers_to_d<br><br>select if(number_of_use = 0, 1, if(a.total < number_of_use, 1, 0)) as result from discount_codes, (select count(*) as total from discount_codes dc, customers_to_discount_codes c2dc where dc.discount_codes_id = c2dc.discount_codes_id and dc.discount_codes = 'e2745e1c' and c2dc.customers_id = '1247') as a where discount_codes = 'e2745e1c' limit 1
I have sourced the reason for this error down to the ot_discount.php file in the folder catalog > includes > modules > order_total.php
The PHP code which causes this error must be somewhere in line 33:
$check_query = tep_db_query(sprintf("select if(number_of_use = 0, 1, if(a.total < number_of_use, 1, 0)) as result from %s, (select count(*) as total from %s dc, %s c2dc where dc.discount_codes_id = c2dc.discount_codes_id and dc.discount_codes = '%s' and c2dc.customers_id = '%s') as a where discount_codes = '%s' limit 1", TABLE_DISCOUNT_CODES, TABLE_DISCOUNT_CODES, TABLE_CUSTOMERS_TO_DISCOUNT_CODES, tep_db_input($sess_discount_code), (int)$customer_id, tep_db_input($sess_discount_code)));
I have tried to resolve this by myself for about nearly two days now - but as I am not being very skilled in PHP and MYSQL I just don´t find a way to resolve this error.
Does anyone have an idea what I would need to do or change in the code above in order to get rid of the error message and make this Contrib to work perfectly in version 2.5 as well on my server? Any hints are being much appreciated.
Thanks in advance,
Claud
#33
Posted 21 October 2010 - 05:03 PM
One possible cause of unintentional liine breaks getting into code is by editing the php code with a rich text editor like MS Word or Open Office Writer. Never use those to edit code of any kind. Simple text editors like Notepad (included in Windows) are good for it. Better yet is a php editor program like the free edition of phpDesigner.
Rule #2: Make sure there are no exceptions to Rule #1.
#34
Posted 21 October 2010 - 06:05 PM
Because this is inside the 'sprintf' function, whatever you add in the appearance of the code is actually counted as part of the string sent to the 'tep_db_query' function.
I also checked the IF() function because I thought that might be the problem - but it is still a valid construct for MySQL v3/4, so thats not a problem.
Also - I'm confused about the following part of the SQL:
select count(*) as total from discount_codes dc, customers_to_d ....
If this valid? Why the space inbetween 'discount_codes' and 'dc', or does the 'dc' mean something special? I haven't seen this before, but its in the PHP code as well, and I have checked my version of 2.5 (which works on my site) and the code is the same so this must be OK, just interested as it looks unusual to me. The subsequent SQL seems to suggest this is the name of a table.
#35
Posted 21 October 2010 - 06:15 PM
Code placed in checkout_process.php:
if (MODULE_ORDER_TOTAL_DISCOUNT_STATUS == 'true') {
if (!empty($discount)) {
$discount_codes_query = tep_db_query("select discount_codes_id from " . TABLE_DISCOUNT_CODES .
" where discount_codes = '" . tep_db_input($sess_discount_code) . "'");
$discount_codes = tep_db_fetch_array($discount_codes_query);
tep_db_perform(TABLE_CUSTOMERS_TO_DISCOUNT_CODES, array('customers_id' => $customer_id,
'discount_codes_id' => $discount_codes['discount_codes_id']));
tep_db_query("update " . TABLE_DISCOUNT_CODES . " set number_of_orders = number_of_orders + 1
where discount_codes_id = '" . (int)$discount_codes['discount_codes_id'] . "'");
tep_session_unregister('sess_discount_code');
}
}
I changed the inner if() clause to read:
//if (!empty($discount)) {
$sess_discount_code = $_SESSION['sess_discount_code'];
if (!empty($sess_discount_code)) {
because the $discount variable wasn't passed for me (I have no idea where this is meant to come from - its not given in checkout_process.php either!). For me, this caused the discount code not to be updated/checked against the database once the order was processed. I don't know whether this is necessary for all. Possibly you could use the corresponding GET variable if the default code doesn't work for you (is it $_GET['discount_code'] ?? ).
#36
Posted 21 October 2010 - 07:03 PM
thank you for your so far posted answers. Yes, the <br><br> loooks strange to me as well and actually I don´t have any idea where it comes from ... but I doubt that this is the source of the problem. The reason for the error must actually lie in a difference between MySQL 4.0.25 and MySQL 4.1.22, because the same code (actually the same files) work properly perfect on my server with MySQL 4.1.22, whereas there must be something in this code which is being rejected by MySQL 4.0.25.
Any idea what this could be or how to adapt the code above to MySQL 4.0.25 ?
Thanks in advance
Claud
#37
Posted 21 October 2010 - 07:15 PM
If you are positive that the line breaks aren't the problem (I've never seen html line break tags inside sql statements or php conditionals) then the next logical step would be to go to the mysql project website and look at the release notes identifying the changes made between those two versions and compare that with the code. Look for something new in 4.1 that the code is using. I doubt it is something bold. More likel ywould be some incorrect syntax that was allowed in 4.0 but disallowed in 4.1. All of the major projects like PHP, mySQL, JS, etc. are moving towards tighter syntax requirements. (by tighter syntax I mean more adherent to the current theories of best practices in coding)
Edited by GraphicsGuy, 21 October 2010 - 07:16 PM.
Rule #2: Make sure there are no exceptions to Rule #1.
#38
Posted 21 October 2010 - 10:47 PM
GraphicsGuy, on 21 October 2010 - 07:15 PM, said:
If you are positive that the line breaks aren't the problem (I've never seen html line break tags inside sql statements or php conditionals) then the next logical step would be to go to the mysql project website and look at the release notes identifying the changes made between those two versions and compare that with the code. Look for something new in 4.1 that the code is using. I doubt it is something bold. More likel ywould be some incorrect syntax that was allowed in 4.0 but disallowed in 4.1. All of the major projects like PHP, mySQL, JS, etc. are moving towards tighter syntax requirements. (by tighter syntax I mean more adherent to the current theories of best practices in coding)
Yes, the exact files were copied to both servers. So the line breaks are not being the problem.
I had also contacted the developer of this Contrib and he was able to clarify the problem:
"MySQL 4.0.25 doesn't support subqueries. I recommend you to downgrade to version 2.4."
So the problem is actually due to an older version of MySQL on that server. Guess I will have to ask my hoster if he can move my domain to another server that has MySQL 4.1.22 installed as well. That should resolve the problem.
#39
Posted 06 November 2010 - 10:40 PM
I was wondering if it is possible to show the discount incl. tax.
So it looks like that the customer get's a greater discount amount
Btw, I read about the % problem, I have also tested the 10% discount in version 2.5, and I had a good tax calculation and total amount
#40
Posted 04 February 2011 - 08:02 PM
kevinb456, on 25 September 2010 - 09:10 PM, said:
This may also work with other paypal mods and other discount mods, but you need to check the variable names to be certain.
This is only for use with the Paypal IPN module set to 'aggregate' mode, not 'per item' (although it would work with a bit of modification).
Open \catalog\includes\modules\payment\paypal_ipn.php
Find the code:
if(MOVE_TAX_TO_TOTAL_AMOUNT == 'True') {
$parameters['amount'] = number_format(($subtotal + $order->info['tax']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
} else {
// default
$parameters['amount'] = number_format($subtotal * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
$parameters['tax'] = number_format($order->info['tax'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
}
(make sure this is correct, there's another 'IF' block that looks very similar in a different loop)
Add the following code directly after:
if (isset($order_total['ot_discount'])) {
$parameters['discount_amount'] = number_format(($order_total['ot_discount']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
}
Done!
The discount will now be included in the paypal payment page, and its event under a special 'discount' heading so your customer can see how much they're saving!
EDIT: I guess you could also set the variable 'discount_amount_cart' instead of 'discount_amount' (see https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables), but this seems to work so I haven't played around too much. 'discount_amount_cart' is infact for the whole cart so this may work better for aggregate mode.









