Problem/Motivation

After creating a test order I went to view order invoice from Invoice tab in Order admin panel. There were store, billing & shipping address, but they were not render properly. I found HTML Tag <br> into the address text and both were one line. Same problem in Invoice Print Section.

Problem issue's image attached.

According to our order router I found a template file called uc-order-invoice.html.twig
I found the following variables for store, billing & shipping address-
{{ store_address }}
{{ order_billing_address }}
{{ order_shipping_address }}

Proposed resolution

I think, we should fix the render issues.

I am new, but I think, for this issue we can use raw twig filter.
{{ store_address|raw }}
{{ order_billing_address|raw }}
{{ order_shipping_address|raw }}

Comments

imrancluster created an issue. See original summary.

imrancluster’s picture

Here is a patch

But don't forgot to clear cache after applying this patch if your twig debug is enable.

Also uploaded a image after applying this patch in 8.x-4.x branch.

tr’s picture

Priority: Minor » Normal

Yes, that's the one place where escaped HTML is still showing in 8.x-4.x that I know of. While your solution works I would rather deal with this issue another way so we don't have to circumvent Twig autoescaping.

The basic problem is we haven't rewritten the template preprocess function and the templates for the invoices. In the preprocess function, the Address objects gets implicitly converted to strings when they are put in the address variables (store_address etc). The conversion is through the __toString() method on Address, which adds those <br>. Twig then autoescapes the <br> because <br> is not on the list of allowed tags.

What I'd like to do is to re-write the entire invoice template and theme functions so the invoice uses the main store theme to render an invoice, rather than pre-set colors and fonts etc. that were chosen for Ubercart back in the D5 days. Our current invoice is ugly and doesn't respect the site's theme.

If you can work on this that would be a great help!

imrancluster’s picture

I am very new for Drupal 8, but I am really interested to work.

I already reply your Email.

  • TR committed 082c772 on 8.x-4.x
    Issue #2663130 by TR: Fix store address token so it doesn't contain...
tr’s picture

Status: Active » Needs review
StatusFileSize
new1.37 KB

The store address was fixed by the commit in #5, this should fix the billing and shipping addresses:

tr’s picture

Status: Needs review » Fixed

Committed.

  • TR committed 1703239 on 8.x-4.x
    Issue #2663130 by TR: Store, Billing & Shipping Address Render problem
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.