Skip to content

Use max to prevent negative sub totals#2351

Merged
glennjacobs merged 8 commits into1.xfrom
fix-discount-negative-subtotal
Dec 8, 2025
Merged

Use max to prevent negative sub totals#2351
glennjacobs merged 8 commits into1.xfrom
fix-discount-negative-subtotal

Conversation

@alecritson
Copy link
Collaborator

This PR prevents reward lines from producing a negative discounted subtotal. Currently, if a BuyXGetY discount grants multiple free items but the cart contains fewer qualifying products, the discount calculation can push the subtotal below zero.

By wrapping the final discounted amount in max(0, ...), we ensure the subtotal never becomes negative. If the discount exceeds the cart line value, the subtotal is simply set to 0.00 until the customer adds enough qualifying items.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@alecritson alecritson requested a review from Copilot December 5, 2025 10:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@alecritson alecritson marked this pull request as ready for review December 5, 2025 11:17
@glennjacobs glennjacobs merged commit 6c777cd into 1.x Dec 8, 2025
45 checks passed
@glennjacobs glennjacobs deleted the fix-discount-negative-subtotal branch December 8, 2025 13:55
@github-project-automation github-project-automation bot moved this from Todo to Done in Roadmap Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants