Score:0

Order receipt mail -> shipping_information variable

ps flag

How can I output the individual information of the variable shipping_information in a template file? For the billing_information variable, I followed How can I get the customer name in an order confirmation e-mail? but that doesn't work in my case.


Hello,

thanks for your answer. I use this template file :

commerce-order-receipt.html.twig

In my estore.theme file i use this code for the billing information, witch works :

function estore_preprocess_commerce_order_receipt(&$vars)
{
      # BillingAddress
      $vars['billing_organization']   = $vars['billing_information']['#profile']->get('address')[0]->organization;
      $vars['billing_given_name']     = $vars['billing_information']['#profile']->get('address')[0]->given_name;
      $vars['billing_family_name']    = $vars['billing_information']['#profile']->get('address')[0]->family_name;
      $vars['billing_address_line1']  = $vars['billing_information']['#profile']->get('address')[0]->address_line1;
      $vars['billing_address_line2']  = $vars['billing_information']['#profile']->get('address')[0]->address_line2;
      $vars['billing_postal_code']    = $vars['billing_information']['#profile']->get('address')[0]->postal_code;
      $vars['billing_locality']       = $vars['billing_information']['#profile']->get('address')[0]->locality;
      $billing_country_code           = $vars['billing_information']['#profile']->get('address')[0]->country_code;
      $billing_lang_code              = $vars['billing_information']['#profile']->get('address')[0]->langcode;
      $billing_countries              = CountryManager::getStandardList();
      $vars['billing_country']        = t($billing_countries[$billing_country_code]->__toString());
      #$vars['billing_country']        = t($billing_countries[$billing_country_code]->getUntranslatedString(), [], ['langcode' => $billing_lang_code ]);
    }

And now I want to extend this function so that I get all the information of the variable shipping_information individually, like with the variable billing_information. But

$vars['shipping_given_name']     = $vars['shipping_information']['#profile']->get('address')[0]->given_name;

dont work.

Regards Maik

No Sssweat avatar
ua flag
Please be more specific and tell us which template file. Also, adding the exact code that you tried is helpful for us. Hopefully you renamed the `hook` part to your actual module name and put the code in a .module file.
Maik avatar
ps flag
Hi. I added the information in my question above. Regards Maik
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.