I need to be able to provide pricing by a number of factors. I have found that I can add a component to a sellable item that would allow me to add those variable prices to the sellable item. I can surface those prices on the front end. Now, when a customer adds an item to the cart, I would like to be able to specify the price. Or if a user has started a cart and logs in, I would like to be able to update the prices in the cart based upon the user type.

It looks like when I add an item to a cart, I am just sending the quantity. The commerce side picks the price and sets a value on PurchaseOptionMoneyPolicy. Here is a block of code where the Sitecore.Commerce.PlugIn.Carts calculates totals:

if (!money.HasPolicy<PurchaseOptionMoneyPolicy>())
                    money.Totals.SubTotal = new Money(str, decimal.Zero);
                    PurchaseOptionMoneyPolicy policy = money.GetPolicy<PurchaseOptionMoneyPolicy>();
                    money.Totals.SubTotal = new Money(str, policy.SellPrice.Amount * money.Quantity);

So I am considering creating a plugin that would allow for updating the sell price amount on a cart, after a line item has been added to the cart or after a user login or other relevant information changed.

I am wondering if this is a safe way to proceed. Are there any actions which might cause the SellPrice amount to be modified after they have been added to the cart?

1 Answer 1


Prices can also be calculated during retrieval of the cart. For example, if the cart was created yesterday and the prices have changed in the mean time, the cart price needs to be re-calculated. The safest way is to add a custom pipeline block to the ICalculateCartLinesPipeline. It should be safe to asume that updates to the cart line prices are always done through this pipeline.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.