How can I load the #totals property for the receipt theme in a custom module? I am trying to manually output the customer's receipt on the checkout complete screen in a custom module.
I have the receipt printing nicely except for the &quot;totals&quot; variable.
My current custom code is the following.
$renderable = array(
      '#theme' =&gt; 'commerce_order_receipt',
      '#order_entity' =&gt; $order,
      '#billing_information' =&gt; NULL,
      '#shipping_information' =&gt; NULL,
      '#payment_method' =&gt; NULL,
      '#totals' =&gt; $this-&gt;orderTotalSummary-&gt;buildTotals($order), // &lt;-- this is the problem
    );

 return array(
      '#theme' =&gt; 'custom_blocks_checkout_complete',
 '#order' =&gt;  \Drupal::service('renderer')-&gt;render($renderable),
    );

As you can see, it's using $this-&gt;orderTotalSummary-&gt;buildTotals($order) to generate the #totals property and this was copied from the OrderReceiptMail class in the Order module. How can I get this property to populate from my custom module please?
Use the service
'#totals' =&gt; \Drupal::service('commerce_order.order_total_summary')-&gt;buildTotals($order),