Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimum Quantity promotion rule #5452

Merged

Conversation

adammathys
Copy link
Contributor

Summary

Introduces a new promotion rule for minimum quantity. This rule will prevent a promotion from applying until a specified quantity threshold is met. It also hooks into PromotionRule#actionable? on other rules to ensure the quantity considered is only for relevant line items.

This promotion rule is helpful for creating "bulk discount" type promotions where you want to offer a discount when a customer orders at least a certain amount of items. Such a promotion is not quite possible with the current rules and actions. (You can sort of come close with the CreateQuantityAdjustments action, but that promotion won't stack properly.)

Admin Not Applied Applied
Screenshot 2023-10-24 at 11 53 29 Screenshot 2023-10-24 at 11 53 58 Screenshot 2023-10-24 at 11 54 08

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

I'm not sure why this padding was ever added, but it made the actions
not line up next to the rules which was silly.
@adammathys adammathys self-assigned this Oct 24, 2023
@adammathys adammathys requested a review from a team as a code owner October 24, 2023 18:55
@github-actions github-actions bot added changelog:solidus_backend Changes to the solidus_backend gem changelog:solidus_core Changes to the solidus_core gem labels Oct 24, 2023
mamhoff added a commit to friendlycart/solidus_friendly_promotions that referenced this pull request Oct 27, 2023
Original PR: solidusio/solidus#5452

This new rule allows for an easy way of providing "bulk" discounts
through the promotion system. It will prevent a promotion from being
applied until it meets a quantity threshold. The rule will also account
for other rules that limit the applicable line items. (e.g.: Taxons,
options values, etc.)

Co-authored-by: Benjamin Wil <[email protected]>
Co-authored-by: Adam Mueller <[email protected]>
@tvdeyen
Copy link
Member

tvdeyen commented Oct 27, 2023

@adammathys thanks. There seems to be related spec failures and the i18n task also complains. Mind to take another look?

@adammathys adammathys force-pushed the minimum-quantity-promotion-rule branch from 220459a to a0d153f Compare October 27, 2023 18:20
@adammathys
Copy link
Contributor Author

@tvdeyen Oops! 🤦🏻‍♂️ Was still using some custom factories, swapped in the default ones so it should be good to go now.

@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

Merging #5452 (cb4692e) into main (af2803a) will increase coverage by 0.01%.
Report is 51 commits behind head on main.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #5452      +/-   ##
==========================================
+ Coverage   88.91%   88.92%   +0.01%     
==========================================
  Files         614      615       +1     
  Lines       14830    14844      +14     
==========================================
+ Hits        13186    13200      +14     
  Misses       1644     1644              
Files Coverage Δ
...p/models/spree/promotion/rules/minimum_quantity.rb 100.00% <100.00%> (ø)
core/lib/spree/app_configuration.rb 99.27% <ø> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

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

This is very valuable!

Small nit

core/app/models/spree/promotion/rules/minimum_quantity.rb Outdated Show resolved Hide resolved
This new rule allows for an easy way of providing "bulk" discounts
through the promotion system. It will prevent a promotion from being
applied until it meets a quantity threshold. The rule will also account
for other rules that limit the applicable line items. (e.g.: Taxons,
options values, etc.)

Co-authored-by: Benjamin Wil <[email protected]>
@adammathys adammathys force-pushed the minimum-quantity-promotion-rule branch from a0d153f to cb4692e Compare November 1, 2023 15:17
@tvdeyen tvdeyen merged commit 54712c7 into solidusio:main Nov 8, 2023
11 checks passed
@adammathys adammathys deleted the minimum-quantity-promotion-rule branch November 8, 2023 16:30
mamhoff added a commit to friendlycart/solidus_friendly_promotions that referenced this pull request Jul 1, 2024
Original PR: solidusio/solidus#5452

This new rule allows for an easy way of providing "bulk" discounts
through the promotion system. It will prevent a promotion from being
applied until it meets a quantity threshold. The rule will also account
for other rules that limit the applicable line items. (e.g.: Taxons,
options values, etc.)

Co-authored-by: Benjamin Wil <[email protected]>
Co-authored-by: Adam Mueller <[email protected]>
mamhoff added a commit to mamhoff/solidus that referenced this pull request Jul 1, 2024
Original PR: solidusio#5452

This new rule allows for an easy way of providing "bulk" discounts
through the promotion system. It will prevent a promotion from being
applied until it meets a quantity threshold. The rule will also account
for other rules that limit the applicable line items. (e.g.: Taxons,
options values, etc.)

Co-authored-by: Benjamin Wil <[email protected]>
Co-authored-by: Adam Mueller <[email protected]>
mamhoff added a commit to friendlycart/solidus_friendly_promotions that referenced this pull request Oct 25, 2024
Original PR: solidusio/solidus#5452

This new rule allows for an easy way of providing "bulk" discounts
through the promotion system. It will prevent a promotion from being
applied until it meets a quantity threshold. The rule will also account
for other rules that limit the applicable line items. (e.g.: Taxons,
options values, etc.)

Co-authored-by: Benjamin Wil <[email protected]>
Co-authored-by: Adam Mueller <[email protected]>
mamhoff added a commit to mamhoff/solidus that referenced this pull request Oct 25, 2024
Original PR: solidusio#5452

This new rule allows for an easy way of providing "bulk" discounts
through the promotion system. It will prevent a promotion from being
applied until it meets a quantity threshold. The rule will also account
for other rules that limit the applicable line items. (e.g.: Taxons,
options values, etc.)

Co-authored-by: Benjamin Wil <[email protected]>
Co-authored-by: Adam Mueller <[email protected]>
mamhoff added a commit to mamhoff/solidus that referenced this pull request Oct 25, 2024
Original PR: solidusio#5452

This new rule allows for an easy way of providing "bulk" discounts
through the promotion system. It will prevent a promotion from being
applied until it meets a quantity threshold. The rule will also account
for other rules that limit the applicable line items. (e.g.: Taxons,
options values, etc.)

Co-authored-by: Benjamin Wil <[email protected]>
Co-authored-by: Adam Mueller <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:solidus_backend Changes to the solidus_backend gem changelog:solidus_core Changes to the solidus_core gem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants