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

mglaman created an issue. See original summary.

bojanz’s picture

Title: Create context value object for order refresh » Create context value object for price resolvers and availability checkers
steveoliver’s picture

Bojanz, if you could give a little direction on how this should be implemented, I'd be happy to tackle it.

steveoliver’s picture

After 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.

Andreas Radloff’s picture

Let 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.

bojanz’s picture

Yes, #5 is why I opened this issue in the first place. Pricelist needs to have that context.

steveoliver’s picture

Assigned: Unassigned » steveoliver

Got it. Started work on PR https://github.com/drupalcommerce/commerce/pull/549. Will be back on it tomorrow.

steveoliver’s picture

Assigned: steveoliver » Unassigned
Status: Active » Needs review

  • bojanz committed f3e2093 on 8.x-2.x authored by steveoliver
    Issue #2803221 by steveoliver, bojanz: Create context value object for...
bojanz’s picture

Status: Needs review » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.