-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Deprecate Promotion any
Match Policy
#4304
Deprecate Promotion any
Match Policy
#4304
Conversation
d1e72cd
to
e23326e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that change very much. I think we should tell people how to re-enable the deprecated behavior in their stores. Very nice touch with the deprecated examples feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple of comments/questions but overall this is a nice job, thanks!
core/db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
Show resolved
Hide resolved
If we reduce the amount of promotions that can be activated, the performance when refreshing the cart improves dramatically. Eventually, this might not be necessary since Solidus#master branch is updated with solidusio#4304 and solidusio#4296. Until those land in master and we are able to update to Solidus 3.2, we need to maintain this fork.
38c394a
to
dded3f0
Compare
core/db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
Outdated
Show resolved
Hide resolved
Using the "any" match policy on promotions creates a lot of difficulty when working with the promotion system. A recent poll on the Solidus Slack indicated that most stores do not use these. It is also from the user's point of view preferable to create separate promotions for each rule in this case, as this will allow store owners to set individual start and end dates and so on for each rule.
dded3f0
to
5732d42
Compare
core/db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb
Outdated
Show resolved
Hide resolved
core/lib/tasks/solidus/split_promotions_with_any_match_policy.rake
Outdated
Show resolved
Hide resolved
A promotion that has a match_policy of "any", but not more than 1 rule, can also have a match_policy of "all" with no change in behavior. This will stop a lot of people from getting deprecation warnings.
This allows us to mark a block as testing deprecated code so that it can easily be identified and removed in the future.
5732d42
to
b3ea863
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thank you 👍
new_promotion = promotion.dup | ||
new_promotion.promotion_rules = [rule] | ||
new_promotion.match_policy = "all" | ||
new_promotion.promotion_actions = promotion.actions.map do |action| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this is going to create many extra actions 🤔 For example, having 3 rules will cause 12 actions to be created due to the nesting. Though, it will end up with the correct set of actions due to promotion_actions =
We are going to remove this preference in Solidus 4.0. The only accepted value for who wants to upgrade is false. Ref solidusio#4304
…g policy Matching "all" rules is the only supported path now. You can have the same effect of the previoys "any" matching policy by creating multiple promotions with the same configuration. Ref solidusio#4304
We are going to remove this preference in Solidus 4.0. The only accepted value for who wants to upgrade is false. Ref solidusio#4304
…g policy Matching "all" rules is the only supported path now. You can have the same effect of the previoys "any" matching policy by creating multiple promotions with the same configuration. Ref solidusio#4304
…g policy Matching "all" rules is the only supported path now. You can have the same effect of the previoys "any" matching policy by creating multiple promotions with the same configuration. This change also removes the rake task we provided to update the existing promotions. That script needs to be executed on previous versions of Solidus only. Ref solidusio#4304
…g policy Matching "all" rules is the only supported path now. You can have the same effect of the previoys "any" matching policy by creating multiple promotions with the same configuration. This change also removes the rake task we provided to update the existing promotions. That script needs to be executed on previous versions of Solidus only. Ref solidusio#4304
…g policy Matching "all" rules is the only supported path now. You can have the same effect of the previoys "any" matching policy by creating multiple promotions with the same configuration. This change also removes the rake task we provided to update the existing promotions. That script needs to be executed on previous versions of Solidus only. Ref solidusio#4304
Matching "all" rules is the only supported path now. You can have the same effect of the previoys "any" matching policy by creating multiple promotions with the same configuration. This change also removes the rake task we provided to update the existing promotions. That script needs to be executed on previous versions of Solidus only. Ref solidusio#4304
Matching "all" rules is the only supported path now. You can have the same effect of the previoys "any" matching policy by creating multiple promotions with the same configuration. This change also removes the rake task we provided to update the existing promotions. That script needs to be executed on previous versions of Solidus only. Ref #4304
Working with the promotion system is made much more complex because Solidus has a feature that allows a promotion to consider an order / line item eligible if any of its rules matches. The same behavior can be obtained - with much greater flexibility - by creating separate promotions for each rule.
Currently, we need to check order-level and line-item level eligibility on once for every line item, and that's only necessary because we allow a match policy of
any
. If onlyall
match_policy promotions existed, we could first check the order eligibility and then check line item eligibility using only line-item applicable rules, which would be a major performance boost and would make the eligibility checks a lot more understandable.Checklist: