Hi George,
We have many features that could effect the item price after you added it to the shopping cart, for instance the discount by quantity which will re-calculate the price on quantity change, also discount by roles and this would also recalculate in cart items if you add another item (that adds user roles) to the shopping cart.
To handle this you can override the method "RazorCart.Core.ActionPipeline.CalculateSubTotal" which should run after item update complete, loop through context.CartList and commit your changes then call base.Execute to run the core method CalculateSubTotal.
protected override PipelineAction[] ListCalculatorPipelineActions()
{
return new PipelineAction[]
{
new MyCalculateSubTotal(),
new CalculateOrderDiscount(),
new CalculateCouponDiscount(),
new CalculateShipping(),
new CalculateHandling(),
new CalculateTax(),
new CalculateFinal()
};
}
class MyCalculateSubTotal : CalculateSubTotal
{
public override PipelineAction Clone() { return new MyCalculateSubTotal(); }
public override int ActionID() { return 1; }
public override string ActionName() { return "Custom.MyCalculateSubTotal()"; }
public override bool IsDisposable() { return false; }
public override ActionEndResult Execute(VATContext context)
{
foreach (var item in context.CartList)
{
item.UnitCost = 1.99M;
RazorCart.Service.Data.Repository.Instance.UpdateShoppingCartItem(
PersistBehavior.Machine,
System.Web.HttpContext.Current.Request.Cookies["_RazorCart-GUID"].Value,
DotNetNuke.Entities.Portals.PortalSettings.Current.UserInfo.Username,
item.CartID, item.Quantity, item.UnitCost, context.StoreID,
DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId);
}
return base.Execute(context);
}
}
Regards,
Wael