Pass PriceCalculator Context to Order Data

Created on 21 November 2024, about 1 month ago

Describe your bug or feature request.

The Order module's PriceCalculator requires a Context object parameter that is used to prepare dummy orders on the fly in order to apply adjustments. I have a situation where I need to calculate the price of a PurchaseableEntity in two different places, but one of them needs to have it's promotion's filtered using the FilterPromotionsEvent supplied by the Promotions module. This event, or for that matter, any order processor, does not have access to the calculator's Context object. We generally handle this by adding arbitrary data to the Order's data field, and retrieving it in our processors. A simple solution would be to pass a specific data key from the Context object to the dummy order that is generated for price calculation. There is already a provider key hard coded to the Order's data to indicate that the order is being used for price calculation. Adding another key, if available on the Context object, would allow more flexibility for Order Processors on orders used for price calculation.

See Slack Conversation:
https://drupal.slack.com/archives/C1TLCCF9B/p1732227541227889

✨ Feature request
Status

Active

Version

2.0

Component

Order

Created by

πŸ‡ΊπŸ‡ΈUnited States alexandersluiter

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024