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

Initial calculators documentation #2511

Merged

Conversation

benjaminwil
Copy link
Contributor

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.

`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
Copy link
Member

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.


## Preferences

Each `Spree::Calculator` has a `preferences` attribute. Its value is a hash that
Copy link
Member

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.

Copy link
Contributor Author

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)
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

@benjaminwil benjaminwil force-pushed the initial_calculators_documentation branch 3 times, most recently from 21e73c2 to d17c659 Compare March 14, 2018 23:47
@benjaminwil benjaminwil force-pushed the initial_calculators_documentation branch from d17c659 to 39eeadb Compare April 6, 2018 18:07
@benjaminwil benjaminwil force-pushed the initial_calculators_documentation branch from 39eeadb to 54fccf7 Compare April 17, 2018 23:00
@benjaminwil benjaminwil force-pushed the initial_calculators_documentation branch from 54fccf7 to 3f9d968 Compare April 18, 2018 17:21
@gmacdougall gmacdougall merged commit 2395380 into solidusio:master Apr 18, 2018
@benjaminwil benjaminwil deleted the initial_calculators_documentation branch April 30, 2018 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants