I want to be able to add a message to invoices that are emailed or printed. But there is no easy way to do this.

I can think of a couple of possibilities.
1. Add the order completion message field to the $info array. Then you could put a print statement in the template to use that field. But that isn't very flexible for situations where you might want to send different messages depending on what is purchased. For example, a non-profit might send one message when it receives a donation and a different message when a member pays dues.
2. Add a field to the order, for example field_receipt_messages. That field could have a default message, or the message could be set by a rule based on what is ordered.

To accomplish the second:
1. add this to the $info array.

  $info = array(
    ...
    'receipt_messages' => $order->field_receipt_messages,
  );

2. Add this to populate the array.

  if (isset($build['commerce_order'][$order->order_id]['field_receipt_messages'])) {
    $info['receipt_messages'] = $build['commerce_order'][$order->order_id]['field_receipt_messages'][0]['#markup'];
  }

3. Add this to the template below the payment info.

                    <?php if (isset($info['receipt_messages'])): ?>
                    <tr>
                      <td align="left">
                        <?php print $info['receipt_messages']; ?>
                      </td>
                    </tr>
                    <?php endif; ?>

Add a condition to the rule to determine what is being purchased and set the value of field_receipt_messages based on that result.

Comments

rsbecker created an issue.