Discounts not applied to order total correctly
| Project: | UC Discounts |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | patch (to be ported) |
I have a discount based on product type and role that is applying correctly (although only in the mode where the discounts show during checkout, not before which is what I would like). The problem is that the discount amount is overriding the total creating a negative amount in the order total preview pane and creating problems for shipping and checkout (for obvious reasons, and there are errors).
Any fixes for this?
Here is what I get on the checkout page from an order for $20 with a 20% discount (i.e $4) applied:
Select a payment method from the following options.
Order total preview: Discounts: -$4.00
Order total: -$4.00
I should have
order total preview: Discounts -$4.00
Order total: $16.00

#1
I believe I fixed this by looking at a patch that made it into the 6.x branch that never got into the 5.x branch involving a call to getTax - if taxes are not applicable or you don't have it enabled at all the whole total price function fails. Correct the lines in uc_discounts.module around line 336 made everything work for me....... I'll try to write a patch and get it submitted, but for now you can change the code to match the following:
$script = "set_line_item('discounts', '". t('Discounts') ."', $discount_total, -1)";drupal_add_js('$(document).ready( function() {
'. $script .'
if (window.getTax) {
getTax();
}
else if (window.render_line_items) {
render_line_items();
}
});', 'inline');
break;
}
}
#2
I've included the patch for this fix.