Overwrite route for Order Details

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Hello!
I m trying to overWrite route for order details. So, I create RoutePrivoder class with this code:

            routes.MapRoute("Plugin.Payments.Receipt.OrderDetails",
               "OrderDetails/{id:int}",
               new { controller = "PaymentReceipt", action = "OrderDetails", id = UrlParameter.Optional },
               new[] { "Nop.Plugin.Payments.Receipt.Controllers" }
          );



And create ActionResult in this controller PaymentReceiptController. I set up breakpoint in my controller on method OrderDetails. And I see that parameter orderId is empty. Could u please tell me why its empty?

public virtual ActionResult OrderDetails(string orderId)
        {
            var order = _orderService.GetOrderById(Convert.ToInt32(orderId));
            if (order == null || order.Deleted || _workContext.CurrentCustomer.Id != order.CustomerId)
                return new HttpUnauthorizedResult();

            //var model = _orderModelFactory.PrepareOrderDetailsModel(order);

            //model.PrintMode = true;

            return View("~/Plugins/Payments.Receipt/Views/PaymentInfo.cshtml");
        }

7 years ago
art_MOO wrote:
Hello!
I m trying to overWrite route for order details. So, I create RoutePrivoder class with this code:

            routes.MapRoute("Plugin.Payments.Receipt.OrderDetails",
               "OrderDetails/{id:int}",
               new { controller = "PaymentReceipt", action = "OrderDetails", id = UrlParameter.Optional },
               new[] { "Nop.Plugin.Payments.Receipt.Controllers" }
          );



And create ActionResult in this controller PaymentReceiptController. I set up breakpoint in my controller on method OrderDetails. And I see that parameter orderId is empty. Could u please tell me why its empty?

public virtual ActionResult OrderDetails(string orderId)
        {
            var order = _orderService.GetOrderById(Convert.ToInt32(orderId));
            if (order == null || order.Deleted || _workContext.CurrentCustomer.Id != order.CustomerId)
                return new HttpUnauthorizedResult();

            //var model = _orderModelFactory.PrepareOrderDetailsModel(order);

            //model.PrintMode = true;

            return View("~/Plugins/Payments.Receipt/Views/PaymentInfo.cshtml");
        }



You have to override


  "orderdetails/{orderId}"


But you did ==>" "OrderDetails/{id:int}","
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.