How to add SKU or other fields (attributes size, color, images) to the commerce-order-receipt.html.twig?

Comments

martinpetracek created an issue. See original summary.

mandus.cz’s picture

This problem is solved as follows:

1) edit fields in /admin/commerce/config/product-variation-types/default/edit/display/summary

2) add {{ order_item.getPurchasedEntity|commerce_entity_render('summary') }} in commerce-order-receipt.html.twig

              {% for order_item in order_entity.getItems %}
              <tr>
                <td>
                  {{ order_item.getQuantity|number_format }} x
                </td>
                <td>
                  {{ order_item.getPurchasedEntity|commerce_entity_render('summary') }}
                </td>
                <td>
                  <span>{{ order_item.label }}</span>
                  <span style="float: right;">{{ order_item.getTotalPrice|commerce_price_format }}</span>
                </td>
              </tr>
              {% endfor %}
in fact, I created a new display called "sku" and didn't use "summary"
demonde’s picture

The simpler way to solve this would be to just add

<td>
  {{ order_item.getPurchasedEntity.getSku }}
</td>  
jsacksick’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

Drupal_hippie’s picture

@demonde
How to see all available options for getPurchasedEntity?
I want to add a product thumbnails to my order confirmation letter products.