How to get Checkout Information in custom mail
/* Get Information For Un support Email to Admin */
$customer = Mage::getSingleton('customer/session')->getCustomer();
//$name = $customer->getName();
$email = $customer->getEmail();
$cart = Mage::getSingleton('checkout/cart')->getQuote();
$productName = array();
/*$skus = array();*/
foreach ($cart->getAllItems() as $item) {
$productName[] = $item->getProduct()->getName();
/*$skus[] = $item->getProduct()->getSku();*/
}
$productNames = implode(', ', $productName);
/*$productSkus = implode(', ', $skus);*/
$quote = Mage::getModel('checkout/session')->getQuote();
$grandTotal = 0;
foreach ($quote->getAllItems() as $item) {
$total += $item->getPriceInclTax() * $item->getQty();
}
$checkout = Mage::getSingleton('checkout/session')->getQuote();
$billAddress = $checkout->getBillingAddress();
Mage::log($billAddress->getData());
//you can get contact number in that
$tele = $billAddress->getTelephone();
$add = $billAddress->getCity();
$street = $billAddress->getStreet1();
$state = $billAddress->getRegion();
$name = $billAddress->getName();
$template_id = 'my_custom_email';
// Who were sending to...
$email_to = '[email protected]';
//$email_to = Mage::getStoreConfig('trans_email/ident_general/email');
//$email_to = Mage::getStoreConfig('trans_email/ident_support/email');
$customer_name = $name;
// Load our template by template_id
$email_template = Mage::getModel('core/email_template')->loadDefault($template_id);
$custom_variable = $name;
$custom_variable1 = $email;
$custom_variable2 = $postCode;
$custom_variable3 = $productNames;
$custom_variable4 = $tele;
$custom_variable5 = $total;
$custom_variable6 = $add;
$custom_variable7 = $street;
$custom_variable8 = $state;
$email_template_variables = array(
'custom_variable' => $custom_variable,
'custom_variable1' => $custom_variable1,
'custom_variable2' => $custom_variable2,
'custom_variable3' => $custom_variable3,
'custom_variable4' => $custom_variable4,
'custom_variable5' => $custom_variable5,
'custom_variable6' => $custom_variable6,
'custom_variable7' => $custom_variable7,
'custom_variable8' => $custom_variable8,
);
$sender_name = Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_STORE_STORE_NAME);
$sender_email = Mage::getStoreConfig('trans_email/ident_general/email');
$email_template->setSenderName($sender_name);
$email_template->setSenderEmail($sender_email);
$email_template->send($email_to, $customer_name, $email_template_variables);