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

Configure promotions via a configuration instance #5738

Merged
merged 1 commit into from
May 3, 2024

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented May 2, 2024

Summary

Prior to this, we would only allow changing the configuration of the promotion system by switching the promotions_configuration_class. The AppConfiguration would then instantiate that class, and one would be able to do all the necessary customizations via the instance.

This allows customizing a promotion configuration and then setting it as the promotion configuration class. It's a lot easier to understand.

Checklist

The following are mandatory for all PRs:

@mamhoff mamhoff requested a review from a team as a code owner May 2, 2024 08:13
@github-actions github-actions bot added the changelog:solidus_core Changes to the solidus_core gem label May 2, 2024
Copy link

codecov bot commented May 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.84%. Comparing base (68b294f) to head (6712bd3).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5738   +/-   ##
=======================================
  Coverage   88.84%   88.84%           
=======================================
  Files         704      704           
  Lines       16761    16761           
=======================================
  Hits        14891    14891           
  Misses       1870     1870           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Prior to this, we would only allow changing the configuration of the
promotion system by switching the `promotions_configuration_class`. The
`AppConfiguration` would then instantiate that class, and one would be
able to do all the necessary customizations via the instance.

This allows customizing a promotion configuration and then setting it as
the promotion configuration class. It's a lot easier to understand.
@mamhoff mamhoff force-pushed the promotions-attribute-accessor branch from 0b09bc1 to 6712bd3 Compare May 2, 2024 12:12
def promotions
@promotion_configuration ||= promotion_configuration_class.new
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it goes beyond this PR, but are we sure we want to use promotions as the interface for a PromotionConfiguration object? I have the feeling something is off here, and this could be a good opportunity to refactor, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're already in the context of a configuration object, and I feel that Spree::Config.promotion_configuration is a mouthful and doesn't provide any more information than Spree::Config.promotions. Especially because some of the methods in the configuration object have more promotion: Spree::Config.promotion_configuration.promotions_adjuster_class.new(order), for example, has more duplication than I would wish for (I'm even thinking of shortening that before the release to just adjuster_class.

So ideally, we'd have something like Spree::Config.promotions.adjuster_class.new(order). IMO, shorter is better.

However, I'm not willing to make this a hill I die on. If y'all think more verbosity is better, I'm all ears.

Copy link
Member

Choose a reason for hiding this comment

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

Explained like this, it makes total sense. I was just missing some context. Going to approve this.

@kennyadsl kennyadsl merged commit 754c58b into solidusio:main May 3, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:solidus_core Changes to the solidus_core gem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants