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 “totals” variable.
My current custom code is the following.
$renderable = array( '#theme' => 'commerce_order_receipt', '#order_entity' => $order, '#billing_information' => NULL, '#shipping_information' => NULL, '#payment_method' => NULL, '#totals' => $this->orderTotalSummary->buildTotals($order), // <-- this is the problem );
return array( '#theme' => 'custom_blocks_checkout_complete', '#order' => Drupal::service('renderer')->render($renderable), );
As you can see, it’s using
$this->orderTotalSummary->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?