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

CommentFileSizeAuthor
#2 uc_discounts_5xdev_fixgettax.patch553 bytesChad_Dupuis
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Chad_Dupuis’s picture

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;
  }
}
Chad_Dupuis’s picture

Status: Active » Patch (to be ported)
FileSize
553 bytes

I've included the patch for this fix.