Skip to content

Freebie item affects product kit discount calculation #702

@vitorrgg

Description

@vitorrgg

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:

  1. 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.
  2. 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

  1. Configure a product_kit_discounts rule with min_quantity: 5, check_all_items: true, discount_lowest_price: true (leve X pague Y style).
  2. Configure a freebies_rules entry with a freebie_coupon pointing to a product cheaper than the regular cart items.
  3. Add 5+ regular items to the cart and apply the freebie coupon.
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions