How to add OrderTotal on Completed page..

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 7 años
Hello..

I'm trying to add OrderTotal on Completed page as OrderId is.

I've added OrderTotal {get; set;} in CheckoutCompletedModel.cs, but I ave challenges with CheckoutController.cs and Completed.cshtml.

Can anybody help me with a step by step solution.

Thanks in advance..
makman
Hace 7 años
Did you look at this in CheckoutController?


        public ActionResult Completed(int? orderId)
        {
...
            //model
            var model = new CheckoutCompletedModel
            {
                OrderId = order.Id,
                OnePageCheckoutEnabled = _orderSettings.OnePageCheckoutEnabled
            };

            return View(model);
        }
Hace 7 años
Hi again, and thanks for the reply.

My CheckoutController is as so:

public ActionResult Completed(int? orderId, decimal? OrderSubTotalExTax, decimal? OrderSubTotalInTax)
        {
            //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);
            }

            Order orderextax  = null;
            if (OrderSubTotalExTax.HasValue)
            {
                //load order by identifier (if provided)
                orderextax = _orderTotalCalculationService.GetShoppingCartSubTotal(orderextax.OrderSubtotalExclTax);
                    
            }

            Order orderintax = null;
            if (OrderSubTotalInTax.HasValue)
            {
                //load order by identifier (if provided)
                orderintax = _orderTotalCalculationService.GetShoppingCartSubTotal(orderintax.OrderSubtotalInclTax);
            }


            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,
                OrderSubTotalInTax = orderextax.OrderSubtotalInclTax,
                OrderSubTotalExTax = orderextax.OrderSubtotalExclTax,
                OnePageCheckoutEnabled = _orderSettings.OnePageCheckoutEnabled,


            };

            return View(model);
        }

and CheckOutcompletedModel.cs is like this

    public partial class CheckoutCompletedModel : BaseNopModel
    {
        public int OrderId { get; set; }
        public decimal OrderSubTotalInTax { get; set; }
        public decimal OrderSubTotalExTax { get; set; }
        public bool OnePageCheckoutEnabled { get; set; }
    }

But I still got the error like this:

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1061: 'Nop.Web.Models.Checkout.CheckoutCompletedModel' does not contain a definition for 'OrderSubTotalInTax' and no extension method 'OrderSubTotalInTax' accepting a first argument of type 'Nop.Web.Models.Checkout.CheckoutCompletedModel' could be found (are you missing a using directive or an assembly reference?)

Source Error:


Line 24:                 <div class="order-number">
Line 25:                     <strong>@T("Checkout.OrderNumber"): @Model.OrderId</strong>
Line 26:                     <strong>@T("Checkout.OrderSubTotal"): @Model.OrderSubTotalInTax</strong>                  
Line 27:                 </div>
Line 28:

Any idea???

Thanks!!!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.