Improve Spree::Stock::Estimator customizability #4267
Closed
spaghetticode
started this conversation in
New Features or Ideas
Replies: 4 comments
|
Yeah, I definitely think this part of the code warrants a redesign to make the components reasonably pluggable and open up the opportunity to rewrite some chunks of this while maintaining full support for the legacy behaviour. Definitely a big project to really do anything with this part of the code, the way it is. |
0 replies
|
It makes sense, @spaghetticode. We could set that block as a |
0 replies
|
FWIW we have a custom Rate Selector implemented. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Currently, the criteria for selecting the appropriate shipping rates is basically a single line block included in the
#shipping_ratesmethod, which is is almost 10 lines long:so, if a store needs to customize only these criteria, at the moment the most reasonable solution is to patch the entire method or use a local subclass of
Spree::Stock::Estimatorthat includes that method patch.I think that extracting these criteria to a separate method, or possibly even better to a specific class with a preference would improve the extendability of the codebase. The class could live inside the
Spree::Stock::Estimatornamespace, something likeSpree::Stock::Estimator::RateSelector, so that we don't add too much indirection by adding a dedicated file for it, especially given we're going to have just a single line of logic with the standard behavior.On the other hand, a full revision of the whole class/process may show better solutions for improving extendability, but it would surely take more time and effort, considering also that it would probably require deprecating the existing code.
All reactions