Hi,
I want to know
Once if customer placed an order for product. How to display Ordered Product image in Order Placed Customer Notification Email Template in Nop 3.7 . I am very new to nopcommerce please do help as soon as possible.
#region Fields
.....
private readonly IPictureService _pictureService;
private readonly MediaSettings _mediaSettings;
#endregion
#region Ctor
public MessageTokenProvider(
....
PictureService pictureService,
MediaSettings mediaSettings)
{
....
this._pictureService = pictureService;
this._mediaSettings = mediaSettings;
}
#endregion
protected virtual string ProductListToHtmlTable(Order order, int languageId, int vendorId)
{ ...
//picture col
sb.AppendLine(string.Format("<th>{0}</th>", ""));
sb.AppendLine(string.Format("<th>{0}</th>", _localizationService.GetResource("Messages.Order.Product(s).Name", languageId)));
...
for (int i = 0; i <= table.Count - 1; i++)
{
var orderItem = table[i];
var product = orderItem.Product;
if (product == null)
continue;
if (vendorId > 0 && product.VendorId != vendorId)
continue;
sb.AppendLine(string.Format("<tr style=\"background-color: {0};text-align: center;\">", _templatesSettings.Color2));
//product picture
var picture = _pictureService.GetPicturesByProductId(product.Id, 1).FirstOrDefault();
//let's check whether this product has some parent "grouped" product
if (picture == null && !product.VisibleIndividually && product.ParentGroupedProductId > 0)
{
picture = _pictureService.GetPicturesByProductId(product.ParentGroupedProductId, 1).FirstOrDefault();
}
string imageUrl = _pictureService.GetPictureUrl(picture, _mediaSettings.CartThumbPictureSize);
sb.AppendFormat("<td><img src=\"{0}\" alt=\"\" /></td>", imageUrl);
//product name
....
}
}
var picture = (await _pictureService.GetPicturesByProductIdAsync(product.Id, 1)).FirstOrDefault();
if (picture == null && !product.VisibleIndividually && product.ParentGroupedProductId > 0)
{
picture = (await _pictureService.GetPicturesByProductIdAsync(product.ParentGroupedProductId)).FirstOrDefault();
}
string fullSizeImageUrl, imageUrl;
(imageUrl, picture) = await _pictureService.GetPictureUrlAsync(picture, _mediaSettings.CartThumbPictureSize);
(fullSizeImageUrl, picture) = await _pictureService.GetPictureUrlAsync(picture);
sb.AppendFormat("<td><img src=\"{0}\" alt=\"\" /></td>", imageUrl);