Skip to content
This repository has been archived by the owner on Sep 4, 2018. It is now read-only.

Provide guidance on designing a custom order or line_item adjustment type #215

Open
dpritchett opened this issue Mar 21, 2014 · 3 comments

Comments

@dpritchett
Copy link
Contributor

This is sort of a companion request to spree/spree#4483

Sample use case

I'm looking at implementing a warranty upsell to specific products in my store. I've built out a simple ProductType model that has_many :product_addons, and now Products have_many addons through :product_types. I've done something very similar before under Spree 2.0 but I'm pretty sure my implementation could be improved. Now that the 2.2 adjustments refactor is out I'm faced with making a few guesses about a solid implementation. I'm sure I'll make it work, but this seems like a good case for a custom adjustments guide.

Possible guide content

  • The adjustment calculator API - which methods to implement? Should I subclass an existing calculator?
  • A sample custom adjustment overview - all of the classes, tables, etc. required to pull it off on the backend. In practice I need admin CRUD screens to manage my custom adjustment options and I need to adjust the _cart_form template to add the adjustments to the frontend, but that is not exactly central to the guide I'm proposing here.
  • Recommendations on extending the OrderPopulator/OrderUpdater - how and where would you safely add extra data to the cart? I pulled this off under 2.0 but again I imagine it could've been done better.
@dpritchett dpritchett changed the title Provide guidance on designing a custom line item adjustment type Provide guidance on designing a custom order or line_item adjustment type Apr 11, 2014
@jhirbour
Copy link

+1

@Senjai
Copy link
Contributor

Senjai commented Apr 11, 2014

👍

Adjustments, promotions, and shipping are probably the most confusing aspects of the spree stack. The hidden gem of adjustments (pre 2-2) was https://github.com/spree/spree/blob/2-1-stable/core/lib/spree/core/calculated_adjustments.rb

Simply included on any model that wishes to create adjustments. Then all it really came down to was finding out where in the checkout process you'd like to implement your adjustment and creating a custom calculator. The creation of custom calculators could be covered better, and the inclusion of some best practices for injecting adjustments into your checkout process.

@uirobot
Copy link

uirobot commented Nov 9, 2014

+1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants