Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
uc_free_product doesn't kick in on taxable items when they have a 100% discount applied to them. Here are some tests I tried:
- Check out item that costs 0 -> you are offered free order method
- Check out tax-free item that costs 5 and use 100 discount -> you are offered free order method
- Check out taxed item that costs 5 and use 100 discount -> Order total is correctly shown at 0 but you are not offered free checkout method
Is this a fault in uc_vat?
Comment | File | Size | Author |
---|---|---|---|
#5 | 920564-free-order-2.patch | 355 bytes | longwave |
#2 | 920564-free-order.patch | 1.54 KB | longwave |
Comments
Comment #1
fletchgqc CreditAttribution: fletchgqc commentedI checked the HTML output on the two test methods - tax-free item with 100% discount and taxed item with 100% discount, and the output was identical apart from the line near the top saying the price.
if (Drupal.jsEnabled) { $(document).ready( function() { set_line_item('subtotal', 'Subtotal', 211.5 [price], -10); } )};
So that didn't help much.
I guess this function in uc_free_order is being passed the wrong value. But why I'm not sure...
$(document).ready(
function() {
$('#edit-panes-payment-current-total').click(function() { free_order_check_total(this.value); });
}
);
Comment #2
longwaveI think this is actually a flaw in uc_line_item_subtotal() in uc_order.line_item.inc, but I have made a patch for uc_vat that seems to work around it for now. I have tested this with uc_vat, uc_coupon (with a 100% off coupon) and uc_free_order installed and it appears to work as expected.
This needs testing before I commit it to uc_vat (or update the patch to change uc_order and reassign it to Ubercart core). A review would also be appreciated, if anyone has the time - though it's incredibly difficult to understand the tangle of JavaScript and AJAX requests that ultimately result in render_line_items() being able to calculate the order total correctly.
Comment #3
fletchgqc CreditAttribution: fletchgqc commentedThanks longwave for looking into this. I only just noticed this patch and things have moved on. Any chance you could re-roll it for the current dev version? I would then test it. I don't know enough about ubercart to review the code, but if it works I will install it on a live site so that should prove it pretty well.
Comment #4
fletchgqc CreditAttribution: fletchgqc commentedActually I just read through the patch and applied it manually to the latest dev version of the module. It worked perfectly and I will install this on a real site. I think you should report the issue to uc_order if that's the real problem, but I think you should commit this patch to uc_vat to solve the problem for now.
Comment #5
longwaveThank you for testing. I have tested the patch some more and unfortunately found issues with applying a 100% coupon in the cart then switching it for a 99% coupon at checkout; the free order was still allowed, although the order was no longer free.
Debugging this is incredibly complex due to the way line item data is cached in JavaScript in uc_payment.js and updated dynamically across the checkout page. It seems to be a combination of issues between uc_order and uc_taxes calculating line items in PHP, and uc_payment doing the same thing in JavaScript. The attached patch is part of another, simplified attempt at fixing this, which solves some issues, but seems to create others - switching this to "needs work" for now, I'm afraid.
Comment #6
longwaveFixing title
Comment #7
kgg CreditAttribution: kgg commentedAs I'm getting this problem:
Bump!
Is there a definitive fix for this?
Karl