The price resolving and availability checking also work outside of an order, so it would be best to add a Context value object that is passed in both cases. The context has a date, store, user for now, and the OrderRefresh populates those from the order.
Comments
Comment #2
bojanz commentedComment #3
steveoliver commentedBojanz, if you could give a little direction on how this should be implemented, I'd be happy to tackle it.
Comment #4
steveoliver commentedAfter speaking with bojanz and mglaman and starting a little work on this that generated lots of 'what about..?' questions, mglaman and I ended up wondering what the real need for this object is. Neither of us can see a reason why we need such a context when we can't remember the original reason it seemed like a good idea and when the values the object holds can be fetched from existing services, as seen in the first case where we attempted to instantiate and pass this object -- ChainPriceResolver. Will leave mglaman and/or bojanz to confirm we actually need this or close it as unnecessary.
Comment #5
Andreas Radloff commentedLet me provide some input as the maintainer of the Commerce Pricelist module.
In order to reproduce the functionality provided by the pricelist module for D7 in D8 a price needs some context. In D7 this was provided by the line item entity that was created each time "the calculated sell price" was displayed to the user. From the line item in D7 we can get the user, order, order date, quantity and so on.
Consider the scenario when a store administrator views or wants to modify an order placed by a customer. This is when we need the User and date context if the price should be determined (from pricelists) by the order date or the customer segment of the user that placed the order, not the current user or date.
Comment #6
bojanz commentedYes, #5 is why I opened this issue in the first place. Pricelist needs to have that context.
Comment #7
steveoliver commentedGot it. Started work on PR https://github.com/drupalcommerce/commerce/pull/549. Will be back on it tomorrow.
Comment #8
steveoliver commentedReady for final review/commit -- https://travis-ci.org/drupalcommerce/commerce/jobs/176835990
Comment #10
bojanz commentedCommitted, thanks!