Facing Some Issue on changing the ShowPricesWithVat Dynamically- Litium 8

Hi
As I need to change the _requestModelAccessor.RequestModel.ChannelModel.Channel.ShowPricesWithVat dynamically from the Website I got an Readonly exception.

Then I tried with below code
var writableCart = _requestModelAccessor.RequestModel.Cart.MakeWritableClone();
writableCart.ShowPricesWithVat = model.status;
using (_securityContextService.ActAsSystem())
{
_cartService.Update(writableCart);
}
Then I got an error
Litium.Application.Data.Batching.BatchDataProcessor2.Update(T entity, DbContext dbContext, BatchData batchData, Action1 postCommitAction)
at Litium.Application.Data.Batching.BatchDataImpl.Execute[T](T entity, ValidationMode validationMode)
at Litium.Application.Data.Batching.BatchDataImpl.WrapAndExecute[T](T entity, ValidationMode validationMode)
at Litium.Application.Data.Batching.BatchDataImpl.Update[T](T entity)
at Litium.Application.Sales.CartServiceImpl.Update(Cart cart)

Can some one help me to figure it out and change the ShowPriceWithVat Dynamically

If you access the cartContext you can call ChangeShowPricesWithVatAsync(true|false) to update the setting on the cart.

2 Likes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.