Hi Team,We are using the legacy cart system and planning to move the serializable cart.In some places of code, we converted the "ICart" to "Cart" type.
Problem: After we enabled the serialize cart then the conversion is not working and returns null.
Question: Once we move to a serializable cart then only we need to use Icart.Is it right? If not, how to convert serializable Icart to Cart?
private readonly IOrderGroupFactory _orderFactory;
private readonly IPromotionService _promotionService;
private readonly Cart _castCart;
public ShoppingCartWrapper(ICart shoppingCart)
_castCart = ShoppingCart as Cart;
You should always use ICart in your code (casting to concrete classes are rarely needed). Then migrating to Serialized Cart will work.
Also beware that while MetaFields need to be registered for Cart (the legacy one) and PurchaseOrder, you don't need to do this for Serialized Cart. It will just (attempt to) serialize the properties you add to it.
Once you moved to Serializable cart, you will not able to cast ICart to Cart (Cart is not compatible with SerializableCart). Stefan is right btw - you should be using ICart always. Why do you need Cart?