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