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);
}
else
{
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?