When using the Minimum Price Qualifier with Fixed Amount Off per Qualifying Item, uc_discounts_alt uses the sum of prices times the amount that is supposed to be discounted for each item, rather than *quantity* of qualifying items. So, if you are trying to have a discount that gives $2 off each product over $10, and you have a $10 product in the cart, the discount will be $2 * $10 ($20) rather than $2 * the number of qualifying products.
The incorrect calculation is performed in the code block below, but solving this problem may require a more involved solution than changing the line the calculates $discount->amount, since we either need to change $order_qualifying_amount to provide a quantity amount, provide a new variable, or go straight for the ideal solution, which would be to completely refactor discount application and qualification processing.
case DISCOUNT_TYPE_FIXED_AMOUNT_OFF_PER_QUALIFYING_ITEM:
//Discount is the total quantity of qualifying items in order (order_qualifying_amount)
//times the discount amount
$discount->amount = $discount->discount_amount * $order_qualifying_amount;
Comments
Comment #1
MadOverlord commentedI just ran into this also -- in my case, I want to give 20% off on items that are more than $10.
However, I am wondering if this is also a nomenclature problem, in that "fixed amount/percentage off per qualifying item" can be interpreted as meaning "apply the discount once for each qualifying item in the order" -- and at least in the case of percentage discounts, at first glance this is what may be happening (the issue you report is more obviously a bug).
Perhaps the best solution is to add new methods:
fixed amount/percentage off applied to all items once per qualifying item
fixed amount/percentage off applied only to each qualifying item
Comment #2
jrust commentedYeah, it just didn't make sense for maximum times applied to be based on the amount of products. It now calculates total qty for all products to which the discount applies and uses that number as the basis for applying the discount for per-item and free item discounts.