Skip to content

[16.0][IMP] pos_loyalty_exclude: Implementing logic to prevent the discount from being applied to excluded products.#1486

Open
SuShanVoong wants to merge 1 commit intoOCA:16.0from
factorlibre:16.0-imp-pos_loyalty_exclude
Open

[16.0][IMP] pos_loyalty_exclude: Implementing logic to prevent the discount from being applied to excluded products.#1486
SuShanVoong wants to merge 1 commit intoOCA:16.0from
factorlibre:16.0-imp-pos_loyalty_exclude

Conversation

@SuShanVoong
Copy link
Copy Markdown

@SuShanVoong SuShanVoong commented Feb 16, 2026

Description

An issue was identified in the loyalty discount logic where products marked with the option “Exclude product from discount programs” were still receiving discounts when added to the cart.

When a product configured as excluded was added to the cart, any active loyalty discount program was still applied to that product, regardless of its exclusion setting.

Root Cause

The exclusion logic in the loyalty module was originally designed to manage point accumulation and free product rewards. However, it did not fully cover all types of loyalty discounts—specifically, discount-based rewards. As a result, products marked as excluded were still considered eligible for certain discount calculations.

This issue affected all discount configurations, including:

  • Order-based discounts
  • Cheapest product discounts

Cases Covered with This Improvement

This update ensures that excluded products are properly ignored across all loyalty discount scenarios:

  • Case 1: Automatic Discounts
    When an excluded product is added to the cart and an automatic loyalty discount program is active:
    The discount is no longer applied to the excluded product.
    The reward button is not highlighted if only excluded products are present in the cart.

  • Case 2: Discount Code Application
    When an excluded product is added to the cart and a discount is applied via promo code:
    The discount is not applied to the excluded product.
    The loyalty exclusion logic is properly enforced.

Additionally, the fix ensures correct behavior across all discount calculation types:

  • Order total–based rewards
  • Cheapest product rewards
  • Specific product rewards

Implemented Solution

The solution introduces proper handling of the loyalty_exclude parameter at the POS JavaScript level.

The following logic adjustments were implemented:

  • _getDiscountableOnOrder: Excluded products are no longer included in the reward amount calculation.
  • _getCheapestLine: Excluded products are ignored when determining the cheapest product in the order.
  • getClaimableRewards: If the cart contains only excluded products, the Rewards button is no longer highlighted.
  • _get_regular_order_lines: apply the filter so that it does not add the excluded products.

These changes ensure that loyalty exclusions are consistently enforced across all discount types and reward calculations.

FL-571-7802

@SuShanVoong
Copy link
Copy Markdown
Author

Evidence of Correct Functionality:

image 2026-02-16_13-55
Grabacion.de.pantalla.desde.2026-02-16.13-43-29.webm

@SuShanVoong SuShanVoong force-pushed the 16.0-imp-pos_loyalty_exclude branch from bb7765f to 2d355bd Compare February 16, 2026 13:13
@LuisAlejandroS
Copy link
Copy Markdown

LGTM

@SuShanVoong SuShanVoong force-pushed the 16.0-imp-pos_loyalty_exclude branch 2 times, most recently from a913437 to 5fea753 Compare February 18, 2026 09:15
…scount from being applied to excluded products.
@SuShanVoong SuShanVoong force-pushed the 16.0-imp-pos_loyalty_exclude branch from 5fea753 to 0e533ee Compare February 18, 2026 12:12
@SuShanVoong
Copy link
Copy Markdown
Author

Can someone review the PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants