public virtual OrderCart CreateOrderCart(Models.OrderCart cart, string visitorId) { var c = new OrderCart(); c.AcceptCondition = false; c.AcceptConversion = false; c.AllowPartialDelivery = cart.AllowPartialDelivery; c.BillingAddress = null; c.CreationDate = DateTime.Now; c.DiscountTotal = cart.DiscountTotal; c.Message = cart.Message; c.ShippingFee = cart.ShippingFee; c.VisitorId = visitorId; c.ShippingFeeLocked = cart.ShippingFeeLocked; foreach (var item in cart.Items) { var i = new CartItem(); i.Packaging = item.Packaging; i.Product = item.Product; i.Quantity = item.Quantity; i.RecyclePrice = item.RecyclePrice; i.SalePrice = item.SalePrice; i.SaleUnitValue = item.SaleUnitValue; i.CreationDate = DateTime.Now; i.LastUpdate = DateTime.Now; i.Discount = item.Discount; i.CatalogPrice = item.CatalogPrice; i.AllowPartialDelivery = item.AllowPartialDelivery; i.IsLocked = item.IsLocked; i.PriceType = item.PriceType; i.ProductStockInfo = item.ProductStockInfo; c.Items.Add(i); } return c; }
public virtual OrderCart CreateOrderCart(Models.UserPrincipal user) { if (user.VisitorId.IsNullOrTrimmedEmpty()) { throw new ArgumentException("Visitor does not be null or empty"); } var cart = new OrderCart(); cart.VisitorId = user.VisitorId; cart.Conveyor = ERPStoreApplication.WebSiteSettings.Shipping.DefaultConveyor; cart.AllowPartialDelivery = ERPStoreApplication.WebSiteSettings.Shipping.AllowPartialDelivery; cart.DiscountTotal = 0; cart.DiscountTotalTaxRate = ERPStoreApplication.WebSiteSettings.Payment.DefaultTaxRate; cart.CreationDate = DateTime.Now; cart.ShippingFeeLocked = false; EventPublisherService.Publish(new Models.Events.OrderCartCreatedEvent() { Cart = cart, UserPrincipal = user, }); return cart; }