The total price of the order in the completed.cshtml

2 years ago
It is possible in version 3.80 (and above) insert information about the total price of the order to completed.cshtml without modifying the model? I need insert this information to conversion script. In version 3.50 this worked:

@model CheckoutCompletedModel
@using Nop.Web.Models.Checkout;
@using Nop.Core;
@using Nop.Core.Infrastructure;
@using Nop.Core.Domain.Orders;
    var _orderService = EngineContext.Current.Resolve<Nop.Services.Orders.IOrderService>();
    var order = _orderService.GetOrderById(Model.OrderId);
    Layout = "~/Views/Shared/_ColumnsOne.cshtml";

<div class="page checkout-page">
    @if (!Model.OnePageCheckoutEnabled)
        @Html.Action("CheckoutProgress", "Checkout", new { step = CheckoutProgressStep.Complete })
    <div class="page-title">
    <div class="page-body checkout-data">
        <div class="section order-completed">
            <div class="title">
            <ul class="details">
                    @T("Checkout.OrderNumber"): @Model.OrderId
                    <a href="@Url.RouteUrl("OrderDetails", new { orderID = Model.OrderId })">@T("Checkout.PlacedOrderDetails")</a>
            <div class="buttons">
                <input type="button" value="@T("Checkout.ThankYou.Continue")" class="button-2 order-completed-continue-button" onclick="setLocation('@Url.RouteUrl("HomePage")')" />

<iframe width="119" height="22" frameborder="0" scrolling="no" src="[email protected]"></iframe>

But in version 3.80 does not work - it says error:

\Views\Checkout\Completed.cshtml(46): error CS0103: The name 'order' does not exist in the current context.
2 years ago
I haven't tested with that particular script before, but you can probably take advantage of the Google Analytics plugin. It already has the {TOTAL} variable exposed on the Thank you page. That's what I do with the Facebook, Bing, and Google remarketing tracking...

It appears to just be a page being called within an the facebook pixel code.

You'd just need to write a bit of simple javascript to open a new window(off screen) and load that URL in it using the already present {TOTAL} variable.

For example, here's the chunk of code I put into the "Tracking code for {ECOMMERCE} part, with {DETAILS} line:" (middle section) of the Google Analytics plugin for tracking Facebook conversions:

(function() {
  var _fbq = window._fbq || (window._fbq = []);
  if (!_fbq.loaded) {
    var fbds = document.createElement('script');
    fbds.async = true;
    fbds.src = '//';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(fbds, s);
    _fbq.loaded = true;
window._fbq = window._fbq || [];
window._fbq.push(['track', '1029384756', {'value':'{TOTAL}','currency':'USD'}]);