Take the community feedback survey now.
Take the community feedback survey now.
Hi everyone,
I want to share a more robust, maintainable approach for applying custom prices (like Floor Sample pricing) in Optimizely Commerce.
Why directly setting PlacedPrice is fragile
Previous code:
lineItem.PlacedPrice = floorSamplePrice;
_cartRepository.SaveCart(cart);
It works - but I found few drawbacks:
If the cart is recalculated (promotions applied, taxes, shipping, quantities changed), the overridden price may be overwritten or ignored.
Promotion engine, discounts, price adjustments expect pricing to come from the catalog/price service, so customizing price this way can lead to unexpected results.
Future upgrades or changes to pricing logic might break your custom override.
Recommended Pattern: Use a Custom Price Processor
Instead of manually setting PlacedPrice, a better pattern is:
Store your custom price in a custom line-item property (e.g. FloorSamplePrice)
Implement a custom IPlacedPriceProcessor that inspects that property and, when present, applies it as the placed price.
Let the rest of the Commerce pricing pipelines (promotions, taxes, recalculation) work as normal — now they will operate with your custom price as the base.
Example Implementation:
[ServiceConfiguration(typeof(IPlacedPriceProcessor))]
public class FloorSamplePriceProcessor : DefaultPlacedPriceProcessor
{
public override void ApplyPlacedPrice(
IOrderGroup orderGroup,
IOrderForm orderForm,
ILineItem lineItem,
IMarket market)
{
// If our custom price is provided, use it
if (lineItem.Properties["FloorSamplePrice"] is string custom &&
decimal.TryParse(custom, out var floorPrice))
{
lineItem.PlacedPrice = floorPrice;
}
else
{
// fallback to standard pricing logic
base.ApplyPlacedPrice(orderGroup, orderForm, lineItem, market);
}
}
}
When adding to cart:
lineItem.Properties["FloorSamplePrice"] = floorSamplePrice.ToString();
_cartRepository.SaveCart(cart);
With that:
This pattern aligns with how Optimizely Commerce expects custom pricing to be handled (via custom pricing providers / price processors).
If anyone else has implemented a similar pattern (customer-specific pricing, ERP-driven price feeds, display-sample pricing, etc.), I’d love to hear your feedback or lessons learned.
Hi everyone,
We’re implementing Floor Sample pricing (Custom Pricing) in an Optimizely Commerce 14 project and I wanted to check if the approach we’re using is considered best practice, or if there’s a more Commerce-native way to handle dynamic pricing.
Right now, when an item qualifies as a Floor Sample, we override the price directly on the line item:
This works, but I’m not sure if overriding
PlacedPriceis the recommended pattern, especially when:promotions need to run on top of the modified price
cart recalculation happens (totals, taxes, fees, etc.)
the user refreshes the cart or shipping methods
the price needs to persist through checkout → purchase order conversion
we later need to audit/track that the price used was a floor-sample price
My questions:
Is directly setting
PlacedPricethe correct way to inject custom/dynamic pricing?Or should we instead be extending a service like:
IPriceServiceIPlacedPriceProcessoror
IShippingPromotionProcessor(if price affects eligibility)?Does changing
PlacedPriceinterfere with the pricing engine or further recalculations?Should we be storing the Floor Sample price in a custom line item property instead of overwriting
PlacedPrice, and let a custom price processor pick it up?Looking for guidance from anyone who has implemented custom/dynamic pricing outside the standard Price Cards. Any best practices or pitfalls would be really helpful!
Thanks