Skip to content

Is it possible to use Price AdjustmentInterface with Cache Context?

I know how Price Adjustment through the AdjustmentInterface (e.g. 10% off prices) work. (MagentoFrameworkPricingAdjustment) (docs: https://developer.adobe.com/commerce/php/development/components/price-adjustments/)

I know how to add a Cache Context so a a new context is created to cache for. (MagentoFrameworkAppHttpContext)

Question: Is it possible to combine those two mechanisms, since I cannot get it working. I confirmed both working individually.

The usecase is as follows. I want to apply a discount percentage based on a customer attribiute value which can differ per customer. So each discount value (10, 20 etc) should become a Cache Context so each first time it is cached for the next time.