How can I display ordered items and shipping info on Drupal Commerce 2.x complete/thank you page?

574 Views Asked by At

I need to edit /complete page. Is there a way to show items from the current order, and possibly shipping info?

Is there something like:

{{order_entity.getOrderShippingInfo}}

or

{{order_entity.getOrderItems}}
2

There are 2 best solutions below

1
David Kovač On

I managed to display ordered items using :

 {% for order_item in order_entity.getItems %}
    {{ order_item.getQuantity|number_format }} x
      {% if order_item.hasPurchasedEntity %}
      {{ order_item.getPurchasedEntity|commerce_entity_render('summary') }}
      {% else %}
      {{- order_item.label -}}
      {% endif %}
      {{- order_item.getTotalPrice|commerce_price_format -}}
  {% endfor %}

Though I still can't get the order Billing or Shipping info.

0
FrankDesign On

Thanks for the code you supplied - it got me started. I found the shipping information. It's added as an 'adjustment' in the order_entity. To display the shipping amount, the code is

{{- order_entity.getAdjustments(['shipping']).0.getAmount|commerce_price_format -}}

Also, if you need the subtotal, the code is

{{- order_entity.getSubtotalPrice|commerce_price_format -}}