public void Execute(OrderPlacedArgs args) { if (!_ecommerceSettings.RewardPointsEnabled) { return; } var order = args.Order; if (order.User == null) { return; } var rewardPointsAppliedAmount = order.RewardPointsAppliedAmount; var pointsToSpend = GetPointsToSpend(rewardPointsAppliedAmount); if (pointsToSpend <= 0) { return; } _session.Transact(session => session.Save(new PointsSpent { Points = -pointsToSpend, User = order.User, Order = order, })); }
public void Execute(OrderPlacedArgs args) { _session.Transact(session => { User currentUser = CurrentRequestData.CurrentUser; if (currentUser != null) { var addresses = session.QueryOver<Address>().Where(address => address.User.Id == currentUser.Id).List(); var order = args.Order; if (!addresses.Contains(order.BillingAddress, AddressComparison.Comparer)) { var clone = order.BillingAddress.ToAddress(session, currentUser); session.Save(clone); addresses.Add(clone); } if (order.ShippingAddress != null && order.ShippingStatus != ShippingStatus.ShippingNotRequired && !addresses.Contains(order.ShippingAddress, AddressComparison.Comparer)) { session.Save(order.ShippingAddress.ToAddress(session, currentUser)); } if (string.IsNullOrEmpty(currentUser.FirstName) && string.IsNullOrEmpty(currentUser.LastName) && order.BillingAddress != null) { currentUser.FirstName = order.BillingAddress.FirstName; currentUser.LastName = order.BillingAddress.LastName; session.Save(currentUser); } } }); }
public void Execute(OrderPlacedArgs args) { _session.Transact(session => { User currentUser = CurrentRequestData.CurrentUser; if (currentUser != null) { var addresses = session.QueryOver <Address>().Where(address => address.User.Id == currentUser.Id).List(); var order = args.Order; if (!addresses.Contains(order.BillingAddress, AddressComparison.Comparer)) { var clone = order.BillingAddress.ToAddress(session, currentUser); session.Save(clone); addresses.Add(clone); } if (order.ShippingAddress != null && order.ShippingStatus != ShippingStatus.ShippingNotRequired && !addresses.Contains(order.ShippingAddress, AddressComparison.Comparer)) { session.Save(order.ShippingAddress.ToAddress(session, currentUser)); } if (string.IsNullOrEmpty(currentUser.FirstName) && string.IsNullOrEmpty(currentUser.LastName) && order.BillingAddress != null) { currentUser.FirstName = order.BillingAddress.FirstName; currentUser.LastName = order.BillingAddress.LastName; session.Save(currentUser); } } }); }
public void Execute(OrderPlacedArgs args) { if (args.Order != null && args.Order.BillingAddress != null && args.Order.SalesChannel == EcommerceApp.DefaultSalesChannel) { var message = string.Format("A <a href='/Admin/Apps/Ecommerce/Order/Edit/{0}'>new order</a> has been placed by {1}.", args.Order.Id, args.Order.BillingAddress.Name); _notificationPublisher.PublishNotification(message, PublishType.Both, NotificationType.AdminOnly); } }
public void Execute(OrderPlacedArgs args) { _session.Transact(session => { var order = args.Order; foreach (var orderLine in order.OrderLines.Where( line => line.ProductVariant.TrackingPolicy == TrackingPolicy.Track)) { var productVariant = orderLine.ProductVariant; if (productVariant != null) productVariant.StockRemaining -= orderLine.Quantity; session.Update(productVariant); } }); }
public void Execute(OrderPlacedArgs args) { if (!_ecommerceSettings.RewardPointsEnabled) return; var order = args.Order; if (order.User == null) return; var rewardPointsAppliedAmount = order.RewardPointsAppliedAmount; var pointsToSpend = GetPointsToSpend(rewardPointsAppliedAmount); if (pointsToSpend <= 0) return; _session.Transact(session => session.Save(new PointsSpent { Points = -pointsToSpend, User = order.User, Order = order, })); }
public void Execute(OrderPlacedArgs args) { _emptyBasket.Empty(); }
public void Execute(OrderPlacedArgs args) { CurrentRequestData.OnEndRequest.Add(new ExecuteLuceneTasks()); }
public void Execute(OrderPlacedArgs args) { var queuedMessage = _messageParser.GetMessage(args.Order); if (queuedMessage != null) _session.Transact(session => session.Save(queuedMessage)); }