-
-
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
Initial calculators documentation #2511
Initial calculators documentation #2511
Conversation
7aae4fe
to
68c69f9
Compare
guides/calculators/overview.md
Outdated
`Spree::Calculator::Shipping::FlatRate` calculator: | ||
|
||
- The new calculator instance would have `calculable_type` of | ||
`Spree::ShippingMethod` (because it is associated with a shipping method, not a |
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 would be best here that calculable
is a polymorphic relationship and possibly link to the rails documentation on that.
guides/calculators/overview.md
Outdated
|
||
## Preferences | ||
|
||
Each `Spree::Calculator` has a `preferences` attribute. Its value is a hash that |
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.
Static model preferences should be introduced here.
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.
Good call. Some initial docs I wrote introducing static model preferences was just merged, so I will link there.
class Calculator::Shipping::CustomShippingCalculator < Spree::ShippingCalculator | ||
... | ||
|
||
def available?(object) |
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 would recommend users against defining something as object
. What is the object being passed in here? Lets explain that.
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'm trying to check that this is possible now. Would it make sense to change object
to order
for this example? Or is the whole example kind of unrealistic, maybe?
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.
Yup. That makes sense. The example is fine as is as a trivial example, but will be helpful for people wondering what object
is.
21e73c2
to
d17c659
Compare
d17c659
to
39eeadb
Compare
Thanks to gmacdougall for his review of my pull request.
39eeadb
to
54fccf7
Compare
54fccf7
to
3f9d968
Compare
I've added an overview of
Spree::Calculator
(and its sub-classes). It goes over calculator attributes, preferences, and what a "calculable" is.Information about creating custom calculators will live in the promotions, shipments, and taxation documentation respectively. So far I've only fleshed out the "Custom shipping calculators" article. The "Custom tax calculators" remains as a stub for now. An article about custom promotion actions has yet to be merged.
In the future, there will also be articles summarizing the functionality/features of all of the built-in calculators.
This is part a larger project to improve Solidus's documentation. See this gist with the high-level table of contents. Where and how this documentation will exist is still up for discussion.