private void loadTheCart(string userName, string templateName) { // New cart var newCart = new Dynamicweb.eCommerce.Orders.Order(); newCart.IsCart = true; List products = new List(); try { products = (List)Session["MS_AddedItemsList"]; } catch { } foreach (SkabelonProduct prod in products) { try { Product myproduct = new Product(); try { myproduct = Product.GetProductByID(prod.getProdID()); myproduct.Save(); } catch (Exception e) { errorMessage("MYTEST3 Skabelon-cs 1124 step1 ErrorGettingProduct" + e.ToString()); } try { double total = System.Convert.ToDouble(prod.getProdTotal()); newCart.CreateOrderLine(myproduct); } catch (Exception e) { errorMessage("MYTEST4 Skabelon-cs 1140 step2 productName:" + myproduct.Name + " id:" + myproduct.ID + " Price:" + myproduct.Price.ToString() + " ErrorAssigningOrderLine " + e.ToString()); } } catch (Exception e) { errorMessage("MYTEST3 Skabelon-cs 1146 overall step3 catch E:" + e.ToString()); } } // Save and persist Cart Dynamicweb.eCommerce.Common.Context.SetCart(newCart); }