Display the customer email address in the shipping address

Edit Mypdf.php

replace

if (!$order->getIsVirtual()) {
    $shippingAddress = $order->getShippingAddress()->format($format);
} else {
    $shippingAddress = '';
}

with

if (!$order->getIsVirtual()) {
    $shippingAddress = $order->getShippingAddress()->format($format);
    //start fooman customisation to display the email address within shipping address
    if (Mage::getStoreConfig('sales_pdf/all/alldisplayemail', $helper->getStoreId())) {
        $excludeKeys = array('entity_id', 'customer_address_id', 'quote_address_id', 'region_id', 'customer_id', 'address_type');
        $oBillingAddress = $order->getBillingAddress()->getData();
        $oShippingAddress = $order->getShippingAddress()->getData();
        $oBillingAddressFiltered = array_diff_key($oBillingAddress, array_flip($excludeKeys));
        $oShippingAddressFiltered = array_diff_key($oShippingAddress, array_flip($excludeKeys));
        $addressDiff = array_diff($oBillingAddressFiltered, $oShippingAddressFiltered);
        if($addressDiff) { // billing and shipping addresses are different
            $shippingAddress .= "<br/>" . $order->getShippingAddress()->getEmail();
        }
        else {
            $shippingAddress .= "<br/>" . $order->getCustomerEmail();
        }
    }
    //end fooman customisation
} else {
    $shippingAddress = '';
}

Still need help? Contact Us Contact Us