Problems with commerce-order-receipt.html.twig

Created on 23 June 2024, 10 months ago
Updated 22 July 2024, 9 months ago

Describe your bug or feature request.

First problem: the customer name is not available.
there was a way to do it with

function my_theme_preprocess_commerce_order_receipt(&$variables) {
  $givenName = $variables['billing_information']['#profile']->get('address')[0]->given_name;
  $variables['given_name'] = $givenName;
  $familyName = $variables['billing_information']['#profile']->get('address')[0]->family_name;
  $variables['family_name'] = $familyName;
}

But that is not working anymore. Even

function my_theme_preprocess_commerce_order_receipt(&$variables) {
  $variables['test'] = "test";
}

does not work.

Second problem: the template file in the theme folder is not used.

Another problem with eMail is, that there is no possibility for attachements.

💬 Support request
Status

Closed: won't fix

Version

2.38

Component

Order

Created by

🇩🇪Germany umac_de

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @umac_de
  • Status changed to Closed: won't fix 9 months ago
  • 🇮🇱Israel jsacksick

    This is a support request which are generally not answered from this queue.

    With the abundance of support available in Drupal Answers, the Drupal focused Stack Exchange site, we are no longer answering support requests in the issue queue.

    Support requests opened here will be closed (won't fix), so please search for existing answers or post new questions at:

    https://drupal.stackexchange.com (using the drupal-commerce tag)

    FYI, once you override the template from the theme, you have to rebuild caches so your override is taken into account.

    Also, you can get the first name and last name using the following code:

      /** @var Drupal\commerce_order\Entity\OrderInterface $order */
      $order = $variables['order_entity'];
      if ($billing_profile = $order->getBillingProfile()) {
          /** @var \Drupal\address\AddressInterface $address */
          $address = $billing_profile->get('address')->first();
         // First name.
         $address->getGivenName(),
         // Last name.
         $address->getFamilyName(),
      }
    
Production build 0.71.5 2024