Answers.Body: <p>The solution was to change the token from </p>
  
  <pre><code>{$billingName}
  </code></pre>
  
  <p>to </p>
  
  <pre><code>{contact.display_name}
  </code></pre>
  
  <p>Following</p>
  
  <ol>
  <li>Administer > communications > message templates civicrm/admin/messageTemplates</li>
  <li>System workflow messages</li>
  <li>Memberships - Receipt (on-line). Change{$billingName} to {contact.display_name} via the tokens picker</li>
  </ol>
  
  <p>Run the membership test-run link.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-01T01:03:06.473Z
Answers.LastActivityDate: 2019-04-01T01:03:06.473Z
Answers.UserDisplayName: Interlated
Answers.Body: <p>The answer posted by Interlated can be problematic and display incorrect name if the contact doing the contribution has different name specific for billing fields. For Eg -</p>
  
  <ul>
  <li>A contribution page is created with profile = "Name and Address".</li>
  <li>When the page is visited online, the profile + billing profile is loaded on the form.</li>
  <li>User unchecks the option <code>My billing address is the same as above</code> and enters a different name and address for billing fields.</li>
  </ul>
  
  <p>The <code>{contact.display_name}</code> will load the original contact name in the mail receipt instead of the expected billing name.</p>
  
  <p>We've also come across this problem and saw some receipt missing the billing fields. This seems to be due to <code>name</code> field in <code>civicrm_address</code> table being set to NULL due to some reason.</p>
  
  <p>Not yet sure how to replicate this, but below patch have fixed the problem for us.</p>
  
  <pre><code>diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php
  index af3dbd233d..31f69c9996 100644
  --- a/CRM/Core/BAO/Address.php
  +++ b/CRM/Core/BAO/Address.php
  @@ -504,6 +504,10 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address {
         $values = [];
         CRM_Core_DAO::storeValues($address, $values);
  
  +      //Fill name of contact if empty.
  +      if (empty($address-&gt;name) &amp;&amp; !empty($address-&gt;contact_id)) {
  +        $address-&gt;name = CRM_Contact_BAO_Contact::displayName($address-&gt;contact_id);
  +      }
         // add state and country information: CRM-369
         if (!empty($address-&gt;location_type_id)) {
           $values['location_type'] = CRM_Utils_Array::value($address-&gt;location_type_id, $locationTypes);
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-27T15:40:29.373Z
Answers.Text: Is this going to be a core patch eventually?
Answers.UserDisplayName: Zachary
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-19T10:31:07.423Z
Answers.LastActivityDate: 2019-09-19T18:44:54.383Z
Answers.LastEditDate: 2019-09-19T18:44:54.383Z
Answers.UserDisplayName: jitendra - fuzion
Body: <p>Emails being generated from new members are now missing 'billingName'. I'm not sure when this happened, we are on 5.11. </p>
  
  <p>The presentation of the output is </p>
  
  <pre><code>Billing Name and Address
  &lt;blank&gt;
  &lt;billing address. 
  </code></pre>
  
  <p>The form has billing_first_name and billing_last_name. </p>
  
  <p><a href="https://i.sstatic.net/8nUWf.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/8nUWf.png" alt="enter image description here"></a></p>
  
  <p>The template web/sites/all/modules/civicrm/xml/templates/message_templates/contribution_online_receipt_html.tpl</p>
  
  <p>has </p>
  
  <pre><code>{elseif $amount GT 0}
     &lt;tr&gt;
      &lt;th {$headerStyle}&gt;
       {ts}Billing Name and Address{/ts}
      &lt;/th&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
      &lt;td colspan="2" {$valueStyle}&gt;
       {$billingName}&lt;br /&gt;
       {$address|nl2br}&lt;br /&gt;
       {$email}
      &lt;/td&gt;
     &lt;/tr&gt;
    {/if}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-29T22:20:19.667Z
Comments.Text: That file location isn't where the actual message template that gets used is stored. You want to check Admin - CiviMail - Message Templates, then click on the System Workflow tab there and look at the contribution receipt one.
Comments.UserDisplayName: Demerit
Tags: <civicontribute><receipts>
Title: Why is the billing name missing from the contributions email receipt?
ThreadText: # Why is the billing name missing from the contributions email receipt?
  
  (Asked by: username_0 on 2019-03-29)
  
  Emails being generated from new members are now missing 'billingName'. I'm not sure when this happened, we are on 5.11.
  
  The presentation of the output is
  
  ```
  Billing Name and Address
  <blank>
  <billing address. 
  
  ```
  
  The form has billing\_first\_name and billing\_last\_name.
  
  [![enter image description here](https://i.sstatic.net/8nUWf.png)](https://i.sstatic.net/8nUWf.png)
  
  The template web/sites/all/modules/civicrm/xml/templates/message\_templates/contribution\_online\_receipt\_html.tpl
  
  has
  
  ```
  {elseif $amount GT 0}
     <tr>
      <th {$headerStyle}>
       {ts}Billing Name and Address{/ts}
      </th>
     </tr>
     <tr>
      <td colspan="2" {$valueStyle}>
       {$billingName}<br />
       {$address|nl2br}<br />
       {$email}
      </td>
     </tr>
    {/if}
  
  ```
  
  **Tags:** civicontribute, receipts
  
  > **Comments:**
  > **username_1**: That file location isn't where the actual message template that gets used is stored. You want to check Admin - CiviMail - Message Templates, then click on the System Workflow tab there and look at the contribution receipt one.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2019-09-19. Score: 4 | Accepted answer
  
  The answer posted by username_0 can be problematic and display incorrect name if the contact doing the contribution has different name specific for billing fields. For Eg -
  
  * A contribution page is created with profile = "Name and Address".
  * When the page is visited online, the profile + billing profile is loaded on the form.
  * User unchecks the option `My billing address is the same as above` and enters a different name and address for billing fields.
  
  The `{contact.display_name}` will load the original contact name in the mail receipt instead of the expected billing name.
  
  We've also come across this problem and saw some receipt missing the billing fields. This seems to be due to `name` field in `civicrm_address` table being set to NULL due to some reason.
  
  Not yet sure how to replicate this, but below patch have fixed the problem for us.
  
  ```
  diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php
  index af3dbd233d..31f69c9996 100644
  --- a/CRM/Core/BAO/Address.php
  +++ b/CRM/Core/BAO/Address.php
  @@ -504,6 +504,10 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address {
         $values = [];
         CRM_Core_DAO::storeValues($address, $values);
  
  +      //Fill name of contact if empty.
  +      if (empty($address->name) && !empty($address->contact_id)) {
  +        $address->name = CRM_Contact_BAO_Contact::displayName($address->contact_id);
  +      }
         // add state and country information: CRM-369
         if (!empty($address->location_type_id)) {
           $values['location_type'] = CRM_Utils_Array::value($address->location_type_id, $locationTypes);
  
  ```
  
  > **Comments:**
  > **username_3**: Is this going to be a core patch eventually?  
  
  ---
  
  ### Answer by username_0 on 2019-04-01. Score: 1
  
  The solution was to change the token from
  
  ```
  {$billingName}
  
  ```
  
  to
  
  ```
  {contact.display_name}
  
  ```
  
  Following
  
  1. Administer > communications > message templates civicrm/admin/messageTemplates
  2. System workflow messages
  3. Memberships - Receipt (on-line). Change{$billingName} to {contact.display\_name} via the tokens picker
  
  Run the membership test-run link.
  
  
  ---
  
  