how to display UserAgreementText on Order Details page?

3 週間 前
nopcommerce 4.60.6

in \Views\Order\Details.cshtml

in here after <td class="product">
<td class="product">
                                        @if (!Model.PrintMode)
                                        {
                                            <em><a href="@(Url.RouteUrl<Product>(new { SeName = item.ProductSeName }))">@item.ProductName</a></em>
                                        }
                                        else
                                        {
                                            @item.ProductName
                                        }
                                        @if (!string.IsNullOrEmpty(item.AttributeInfo))
                                        {
                                            <div class="attributes">
                                                @Html.Raw(item.AttributeInfo)
                                            </div>
                                        }
                                        @if (!string.IsNullOrEmpty(item.RentalInfo))
                                        {
                                            <div class="rental-info">
                                                @Html.Raw(item.RentalInfo)
                                            </div>
                                        }
                                        @if (item.DownloadId > 0)
                                        {
                      <iframe src='@Url.RouteUrl("GetDownload", new { orderItemId = item.OrderItemGuid })' style='width:100%;height:30px;border:0;margin-top:10px;'></iframe>
                                        }
                                        @if (item.LicenseId > 0)
                                        {
                                            <div class="download license">
                                                <a href="@Url.RouteUrl("GetLicense", new {orderItemId = item.OrderItemGuid})">@T("DownloadableProducts.Fields.DownloadLicense")</a>
                                            </div>
                                        }
                                        @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.OrderDetailsProductLine, additionalData = item })
                                    </td>


i tried this
@Url.RouteUrl("GetDownload", new { orderItemId = item.UserAgreementText })

and this
@item.UserAgreementText

it doesn't work...

i need to display some field from product on order details page when product is paid, maybe gtin or manufacturer part number

how can i do it please?
2 週間 前
If you want to display any product-related information that is not available on this page, then you can inject IProductService on top of the page and then use
@{
var product = await productService.GetProductByIdAsync(item.Id);
}
.
.
.
//now display any product info like this:
<div>@product.Name</div>
2 週間 前
bhautik1907 wrote:
If you want to display any product-related information that is not available on this page, then you can inject IProductService on top of the page and then use
@{
var product = await productService.GetProductByIdAsync(item.Id);
}
.
.
.
//now display any product info like this:
<div>@product.Name</div>


Didn't understand the first part.

Can you please, give me example for this file mysite\Views\Order\Details.cshtml
I want to display ManufacturerPartNumber or UserAgreementText in this page.
2 週間 前
bhautik1907 wrote:
If you want to display any product-related information that is not available on this page, then you can inject IProductService on top of the page and then use
@{
var product = await productService.GetProductByIdAsync(item.Id);
}
.
.
.
//now display any product info like this:
<div>@product.Name</div>


Can you please help me?
2 週間 前
" on top of the page:"
- after all existing @model / @using / @inject lines at the top of the page:
@inject Nop.Services.Catalog.IProductService productService
@{
  var product = await productService.GetProductByIdAsync(item.Id);
}


"now display any product info like this:"
<div>@product.ManufacturerPartNumber</div>

1 週間 前
New York wrote:
" on top of the page:"
- after all existing @model / @using / @inject lines at the top of the page:
@inject Nop.Services.Catalog.IProductService productService
@{
  var product = await productService.GetProductByIdAsync(item.Id);
}


"now display any product info like this:"
<div>@product.ManufacturerPartNumber</div>



Yes,  @danielaguero have a look at this code sample.
1 週間 前
New York wrote:
" on top of the page:"
- after all existing @model / @using / @inject lines at the top of the page:
@inject Nop.Services.Catalog.IProductService productService
@{
  var product = await productService.GetProductByIdAsync(item.Id);
}


"now display any product info like this:"
<div>@product.ManufacturerPartNumber</div>



It doesn't work. It breaks the order detail page after I insert that code.

In \Views\Order\Details.cshtml on top of the code I do it this way:
@model OrderDetailsModel

@using Nop.Core.Domain.Catalog
@inject Nop.Services.Catalog.IProductService productService
@{
  var product = await productService.GetProductByIdAsync(item.Id);
}


@{
    if (!Model.PrintMode)
    {
        Layout = "_ColumnsOne";
    }
    else
    {
        Layout = "_Print";
    }
    //title
    NopHtml.AddTitleParts(T("PageTitle.OrderDetails").Text);
    //page class
    NopHtml.AppendPageCssClassParts("html-order-details-page");
}
...

Then in the body I do this:
<tbody>
                            @foreach (var item in Model.Items)
                            {
                                <tr>
                                    @if (Model.ShowSku)
                                    {
                                        <td class="sku">
                                            <label class="td-title">@T("Order.Product(s).SKU"):</label>
                                            <span class="sku-number">@item.Sku</span>
                                        </td>
                                    }
                                    @if (Model.ShowProductThumbnail)
                                    {
                                        <td class="picture">
                                            <a href="@(Url.RouteUrl<Product>(new {SeName = item.ProductSeName}))"><img alt="@item.Picture.AlternateText" src="@item.Picture.ImageUrl" title="@item.Picture.Title" /></a>
                                        </td>
                                    }
                                    <td class="product">
                                        @if (!Model.PrintMode)
                                        {
                                            <em><a href="@(Url.RouteUrl<Product>(new { SeName = item.ProductSeName }))">@item.ProductName</a></em>
<div>@product.ManufacturerPartNumber</div>
                                        }
                                        else
                                        {
                                            @item.ProductName
                                        }
                                        @if (!string.IsNullOrEmpty(item.AttributeInfo))
                                        {
                                            <div class="attributes">
                                                @Html.Raw(item.AttributeInfo)
                                            </div>
                                        }
                                        @if (!string.IsNullOrEmpty(item.RentalInfo))
                                        {
                                            <div class="rental-info">
                                                @Html.Raw(item.RentalInfo)
                                            </div>
                                        }
...
1 週間 前
bhautik1907 wrote:
" on top of the page:"
- after all existing @model / @using / @inject lines at the top of the page:
@inject Nop.Services.Catalog.IProductService productService
@{
  var product = await productService.GetProductByIdAsync(item.Id);
}


"now display any product info like this:"
<div>@product.ManufacturerPartNumber</div>



Yes,  @danielaguero have a look at this code sample.


It does not work. :(
1 週間 前
I don't believe this code should be at the top of the page...

@{
  var product = await productService.GetProductByIdAsync(item.Id);
}

... instead it should be within the foreach loop that iterates each item. Find the foreach in the Details view and add like so...

@foreach (var item in Model.Items)
{
    var product = await productService.GetProductByIdAsync(item.Id);
    // ...
    // other code
    // ...
}
1 週間 前
danielaguero wrote:
" on top of the page:"
- after all existing @model / @using / @inject lines at the top of the page:
@inject Nop.Services.Catalog.IProductService productService
@{
  var product = await productService.GetProductByIdAsync(item.Id);
}


"now display any product info like this:"
<div>@product.ManufacturerPartNumber</div>


Let me provide you with a sample code step by step.

1. Inject Product service on the top of the page.  

@using Nop.Core.Domain.Catalog
@inject Nop.Services.Catalog.IProductService productService

2. Now fetch the product where foreach iteration is happening.  check the following code.

   @foreach (var item in Model.Items)
  {
      var product = await productService.GetProductByIdAsync(item.ProductId);
      <tr>
          <td>
              <div>@product.ManufacturerPartNumber</div>
          </td>
          @if (Model.ShowSku)
          {
              <td class="sku">
                  <label class="td-title">@T("Order.Product(s).SKU"):</label>
                  <span class="sku-number">@item.Sku</span>
              </td>
          }
           .
           .
           .

Yes,  @danielaguero have a look at this code sample.

It does not work. :(