public ActionResult Completed(int? orderId) { //validation if ((_workContext.CurrentCustomer.IsGuest() && !_orderSettings.AnonymousCheckoutAllowed)) return new HttpUnauthorizedResult(); Order order = null; if (orderId.HasValue) { //load order by identifier (if provided) order = _orderService.GetOrderById(orderId.Value); } if (order == null) { order = _orderService.SearchOrders(_storeContext.CurrentStore.Id, 0, _workContext.CurrentCustomer.Id, null, null, null, null, null, null, null, 0, 1) .FirstOrDefault(); } if (order == null || order.Deleted || _workContext.CurrentCustomer.Id != order.CustomerId) { return RedirectToRoute("HomePage"); } //model var model = new CheckoutCompletedModel() { OrderId = order.Id, OnePageCheckoutEnabled = UseOnePageCheckout() }; return View(model); }
public ActionResult Completed(int? orderId) { //validation if ((_workContext.CurrentCustomer.IsGuest() && !_orderSettings.AnonymousCheckoutAllowed)) return new HttpUnauthorizedResult(); Order order = null; if (orderId.HasValue) { //load order by identifier (if provided) order = _orderService.GetOrderById(orderId.Value); } if (order == null) { order = _orderService.SearchOrders(storeId: _storeContext.CurrentStore.Id, customerId: _workContext.CurrentCustomer.Id, pageSize: 1) .FirstOrDefault(); } if (order == null || order.Deleted || _workContext.CurrentCustomer.Id != order.CustomerId) { return RedirectToRoute("HomePage"); } //disable "order completed" page? if (_orderSettings.DisableOrderCompletedPage) { return RedirectToRoute("OrderDetails", new {orderId = order.Id}); } //model var model = new CheckoutCompletedModel { OrderId = order.Id, OnePageCheckoutEnabled = _orderSettings.OnePageCheckoutEnabled }; return View(model); }
public ActionResult Completed() { //validation if ((_workContext.CurrentCustomer.IsGuest() && !_orderSettings.AnonymousCheckoutAllowed)) return new HttpUnauthorizedResult(); //model var model = new CheckoutCompletedModel(); var orders = _orderService.GetOrdersByCustomerId(_workContext.CurrentCustomer.Id); if (orders.Count == 0) return RedirectToAction("Index", "Home"); else { var lastOrder = orders[0]; model.OrderId = lastOrder.Id; } return View(model); }
//add by hz public ActionResult Completed(string successOrderList) { //validation if ((_workContext.CurrentCustomer.IsGuest() && !_orderSettings.AnonymousCheckoutAllowed)) return new HttpUnauthorizedResult(); //model var model = new CheckoutCompletedModel(); if (!String.IsNullOrEmpty(successOrderList)) { model.OrderIds = successOrderList.Split(','); Array.ForEach(model.OrderIds, s => s.Trim()); model.OrderId = 0; } else return RedirectToRoute("HomePage"); foreach (string s in model.OrderIds) { int orderId; if (Int32.TryParse(s, out orderId)) { var vendor = _orderService.GetVendorByOrderId(orderId); var vendorOrderCheckout = new CheckoutCompletedVendorOrderModel(); vendorOrderCheckout.Vendor = vendor; vendorOrderCheckout.OrderId = orderId; model.CheckoutVendorOrders.Add(vendorOrderCheckout); } } return View(model); }