Bug description
When a cart has an active freebie rule (e.g. a gift product added via coupon) alongside a product_kit_discounts rule that uses discount_lowest_price: true and check_all_items: true, the freebie item is incorrectly included in the kit discount calculation in two ways:
- Price: because the freebie has a lower price than the regular products, it becomes the "lowest price" used as the discount base value, drastically reducing the kit discount.
- Quantity: the freebie item is counted towards the minimum quantity required to trigger the kit rule, which can incorrectly activate the discount.
Steps to reproduce
- Configure a
product_kit_discounts rule with min_quantity: 5, check_all_items: true, discount_lowest_price: true (leve X pague Y style).
- Configure a
freebies_rules entry with a freebie_coupon pointing to a product cheaper than the regular cart items.
- Add 5+ regular items to the cart and apply the freebie coupon.
- The
extra_discount value will be computed using the freebie's price instead of the regular items' price.
Expected behavior
Freebie products should be excluded from product_kit_discounts calculations entirely — neither their price nor their quantity should influence the kit rule.
Actual behavior
With 11 regular items (R$15.90 each) + 1 freebie (R$6.90):
|
Without fix |
Expected |
| Lowest price used |
R$6.90 (freebie) |
R$15.90 |
| Kit discount (2 kits) |
R$13.80 |
R$31.80 |
| Freebie discount |
R$6.90 |
R$6.90 |
| Total |
R$20.70 |
R$38.70 |
Bug description
When a cart has an active freebie rule (e.g. a gift product added via coupon) alongside a
product_kit_discountsrule that usesdiscount_lowest_price: trueandcheck_all_items: true, the freebie item is incorrectly included in the kit discount calculation in two ways:Steps to reproduce
product_kit_discountsrule withmin_quantity: 5,check_all_items: true,discount_lowest_price: true(leve X pague Y style).freebies_rulesentry with afreebie_couponpointing to a product cheaper than the regular cart items.extra_discountvalue will be computed using the freebie's price instead of the regular items' price.Expected behavior
Freebie products should be excluded from
product_kit_discountscalculations entirely — neither their price nor their quantity should influence the kit rule.Actual behavior
With 11 regular items (R$15.90 each) + 1 freebie (R$6.90):