[add-on] Discount Code (support)
#1
Posted 11 May 2010 - 01:40 PM
#2
Posted 12 May 2010 - 08:10 PM
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
Here is the ot_tax.php as requested:
<?php
/*
$Id: ot_tax.php 1739 2007-12-20 00:52:16Z hpdl $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright © 2003 osCommerce
Released under the GNU General Public License
*/
class ot_tax {
var $title, $output;
function ot_tax() {
$this->code = 'ot_tax';
$this->title = MODULE_ORDER_TOTAL_TAX_TITLE;
$this->description = MODULE_ORDER_TOTAL_TAX_DESCRIPTION;
$this->enabled = ((MODULE_ORDER_TOTAL_TAX_STATUS == 'true') ? true : false);
$this->sort_order = MODULE_ORDER_TOTAL_TAX_SORT_ORDER;
$this->output = array();
}
function process() {
global $order, $currencies;
reset($order->info['tax_groups']);
while (list($key, $value) = each($order->info['tax_groups'])) {
if ($value > 0) {
$this->output[] = array('title' => $key . ':',
'text' => $currencies->format($value, true, $order->info['currency'], $order->info['currency_value']),
'value' => $value);
}
}
}
function check() {
if (!isset($this->_check)) {
$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_TAX_STATUS'");
$this->_check = tep_db_num_rows($check_query);
}
return $this->_check;
}
function keys() {
return array('MODULE_ORDER_TOTAL_TAX_STATUS', 'MODULE_ORDER_TOTAL_TAX_SORT_ORDER');
}
function install() {
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Display Tax', 'MODULE_ORDER_TOTAL_TAX_STATUS', 'true', 'Do you want to display the order tax value?', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_TAX_SORT_ORDER', '3', 'Sort order of display.', '6', '2', now())");
}
function remove() {
tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
}
?>
#3
Posted 13 May 2010 - 04:03 PM
I installed the module to the instructions exactly and activated it. I have entered a discount code against a product and run through the purchase of that product. The discount line is not appearing in the 'Order Confirmation' screen of the checkout process and the total is not affected by the discount.
Is anybody else having an issue with this module? Any advice appreciated...
#4
Posted 13 May 2010 - 04:32 PM
#5
Posted 13 May 2010 - 10:00 PM
#6
Posted 19 May 2010 - 06:07 PM
robweidman, on 13 May 2010 - 10:00 PM, said:
I installed the module to the instructions exactly and activated it. I have entered a discount code against a product and run through the purchase of that product. The discount line is not appearing in the 'Order Confirmation' screen of the checkout process and the total is not affected by the discount. i change the sort order too, but still not working.
Help anyone,
Thanks in advanced.
#7
Posted 27 May 2010 - 06:23 PM
This time my experience:
Discount on category -> tax calculation works with version 2.4.
Discounts on individual products -> tax calculation does not work
Fixed amount as a discount (eg 5 €) on total -> tax calculation does not work
Display value after coupon: ---> There is always value without tax
In short, the part is not usable.
Greetings
#8
Posted 24 August 2010 - 05:46 AM
Rule #2: Make sure there are no exceptions to Rule #1.
#9
Posted 24 August 2010 - 09:24 AM
#10
Posted 24 August 2010 - 01:30 PM
rhubarb, on 24 August 2010 - 09:24 AM, said:
That sounds like a different (similar) contribution. Perhaps CCGV (Credit Class Gift Voucher). The Discount Code contrib's admin panel section is titled Discount Codes and I don't see any place to enter coupon description.
Rule #2: Make sure there are no exceptions to Rule #1.
#11
Posted 25 August 2010 - 01:56 PM
NN
#12
Posted 25 August 2010 - 02:52 PM
nacid, on 25 August 2010 - 01:56 PM, said:
NN
As far as I can tell, this contrib doesn't have that ability. It is pretty simple code and bare bones functions. That is actually why I am using it. I have quite a few mods in my store and adding this one avoided some of the complications the other more robust ones were.
If you wanted to add that feature to this, it shouldn't be too complicated for a osc experienced coder to create a java script to display it on page and update the total and then put an "apply" button next to the code entry box that would trigger the javascript.
Rule #2: Make sure there are no exceptions to Rule #1.
#13
Posted 25 August 2010 - 03:07 PM
GraphicsGuy, on 25 August 2010 - 02:52 PM, said:
If you wanted to add that feature to this, it shouldn't be too complicated for a osc experienced coder to create a java script to display it on page and update the total and then put an "apply" button next to the code entry box that would trigger the javascript.
thanks for the prompt reply.
code is working fine. just you are not able to see the discount unless put credit card details and go to the next page.
#14
Posted 25 August 2010 - 03:38 PM
GraphicsGuy, on 25 August 2010 - 02:52 PM, said:
If you wanted to add that feature to this, it shouldn't be too complicated for a osc experienced coder to create a java script to display it on page and update the total and then put an "apply" button next to the code entry box that would trigger the javascript.
Any idea why it's not working with PayPal IPN v2.3.4.6 payment module?
Paypal get the total without the discount.
Thanks
#15
Posted 25 August 2010 - 04:48 PM
nacid, on 25 August 2010 - 03:38 PM, said:
Paypal get the total without the discount.
Thanks
I haven't tested mine on PayPal. Just guessing here, but maybe the PayPal IPN module takes the subtotal, shipping and tax amounts and calculates its own total. In which case the IPN module would have to be modified.
Or the simple workaround would be to change the sort order in the admin->modules->Order Total page so that the Discount Code module is ahead of the subtotal. (that is assuming that the reason for the PayPal problem is that it is calculating its own final total.
Of course you would have to check your local sales tax laws before changing when the sales tax is calculated. Some jurisdictions require discounts to be deducted after tax is computed so that the customer is paying sales tax on the full amount. In determining that you may have to consider how you will be using the discount. If it is promotional discount or coupon, I think most jurisdictions will allow pretax deducting of the discount. But if it is described as a rebate almost all jurisdictions require it to be deducted after tax computation.
Rule #2: Make sure there are no exceptions to Rule #1.
#16
Posted 31 August 2010 - 05:08 PM
Rick H
Edited by rickharr, 31 August 2010 - 05:11 PM.
#17
Posted 31 August 2010 - 05:37 PM
It's a shame. It is a nice simple approach to coupon codes with a neat clean admin screen.
Rule #2: Make sure there are no exceptions to Rule #1.
#18
Posted 24 September 2010 - 02:47 PM
Great Addon.
There is one problem, the discount isn't been carried on to PayPal.
Is there any fix for this please.
Thanks.
#19
Posted 25 September 2010 - 08:03 PM
I'm getting my shop setup for 1st october and this is one of the last hurdles (getting it to work with paypal IPN 2.3.4.6) - so hopefully I'll find a solution... I'll keep you all updated of course.
Otherwise this is a very well constructed mod and I likey likey!
#20
Posted 25 September 2010 - 09:10 PM
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.
Edited by kevinb456, 25 September 2010 - 09:12 PM.









