how do I print order notes (when display to customer = true) into the PDF invoice

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 năm cách đây
we have a nice clean pdf invoice but i want to use the smart new 'display order note to customer' function in admin so that if an order note is to be displayed to the customer then that order note will also be published to the pdf


i guess the logic would be - if order note exists and order note display to customer = true   then  print to pdf




any ideas anyone?
14 năm cách đây
a little bump

i put suggestion for this on codeplex - if anyone else is interested in this feature, go vote
http://nopcommerce.codeplex.com/workitem/7888
13 năm cách đây
Was wondering if anyone ever figured out how to add customer viewable order notes to PDF or if this was implemented.
13 năm cách đây
the work item is still on codeplex but it's closed - for the time being at least

pity, it seems like a very useful feature -

at present, once we print an invoice, any customer specific information must be written by hand

this is a problem because there is then no record of it - unless you have a paper copy + you write it twice !

- hayden
13 năm cách đây
Below is what you will need to add to PDFHelper.cs in order to get Customer Viewable notes to show up on your PDF Invoice. It generates the table exactly the same as Products does and loops through the OrderNotes class only displaying those notes viewable to the customer.

PDFHelper.cs > Methods > PrintOrderToPdf

On my PDF I have the code below inserted directly above 'PdfDocumentRenderer' so it shows up at the bottom of the document below order total, but you should be able to put it wherever you want in the pdf.

//OrderNotes
            Paragraph p14 = sec.AddParagraph(LocalizationManager.GetLocaleResourceString("order.Notes", languageId));
            p14.Format.Font.Bold = true;
            p14.Format.Font.Color = Colors.Black;

            sec.AddParagraph();

            var tbl1 = sec.AddTable();

            tbl1.Borders.Visible = true;
            tbl1.Borders.Width = 1;

            tbl1.AddColumn(Unit.FromCentimeter(6));
            tbl1.AddColumn(Unit.FromCentimeter(12));
            
            Row header1 = tbl1.AddRow();

            header1.Cells[0].AddParagraph(LocalizationManager.GetLocaleResourceString("order.OrderNotes.CreatedOn", languageId));
            header1.Cells[0].Format.Alignment = ParagraphAlignment.Center;

            header1.Cells[1].AddParagraph(LocalizationManager.GetLocaleResourceString("order.OrderNotes.Note", languageId));
            header1.Cells[1].Format.Alignment = ParagraphAlignment.Center;

            for (int i = 0; i < order.OrderNotes.Count; i++)
            {
                if (order.OrderNotes[i].DisplayToCustomer == true)
                {
                    Row noteRow = tbl1.AddRow();

                    noteRow.Cells[0].AddParagraph(DateTimeHelper.ConvertToUserTime(order.OrderNotes[i].CreatedOn, DateTimeKind.Utc).ToString());
                    noteRow.Cells[1].AddParagraph(OrderManager.FormatOrderNoteText(order.OrderNotes[i].Note).ToString());
                }
            }
13 năm cách đây
Nice one Stork1

I look forward to implementing this, i lost so much hair in April I gave up hoping I'd ever get a solution.


Thank you

- hayden
13 năm cách đây
Stork1 wrote:
Below is what you will need to add to PDFHelper.cs in order to get Customer Viewable notes to show up on your PDF Invoice.

Thanks. It'll be added to the next release (disabled by default).

BTW line breaks are rendered as html tag <br />. You need to replace
noteRow.Cells[1].AddParagraph(OrderManager.FormatOrderNoteText(order.OrderNotes[i].Note).ToString());

with
noteRow.Cells[1].AddParagraph(HtmlHelper.ConvertHtmlToPlainText(OrderManager.FormatOrderNoteText(orderNote.Note)).ToString());
13 năm cách đây
thanks for this guys, in the end i used the code to create a simpler looking result on the rendered page :


//OrderNotes
            sec.AddParagraph();
            sec.AddParagraph(LocalizationManager.GetLocaleResourceString("order.Notes", languageId));
            sec.AddParagraph();

            for (int i = 0; i < order.OrderNotes.Count; i++)
            {
                if (order.OrderNotes[i].DisplayToCustomer == true)
                {
                    sec.AddParagraph(HtmlHelper.ConvertHtmlToPlainText(OrderManager.FormatOrderNoteText(order.OrderNotes[i].Note)).ToString());
                    sec.AddParagraph();
                    sec.AddParagraph();
                }
            }
13 năm cách đây
haydie wrote:
thanks for this guys, in the end i used the code to create a simpler looking result on the rendered page :


//OrderNotes
            sec.AddParagraph();
            sec.AddParagraph(LocalizationManager.GetLocaleResourceString("order.Notes", languageId));
            sec.AddParagraph();

            for (int i = 0; i < order.OrderNotes.Count; i++)
            {
                if (order.OrderNotes[i].DisplayToCustomer == true)
                {
                    sec.AddParagraph(HtmlHelper.ConvertHtmlToPlainText(OrderManager.FormatOrderNoteText(order.OrderNotes[i].Note)).ToString());
                    sec.AddParagraph();
                    sec.AddParagraph();
                }
            }


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