Magento Forum

Auto email codes
 
Mongey
Jr. Member
 
Total Posts:  2
Joined:  2008-06-29
 

Hey,
I’ wondering if anyone is capable of making something that instantly emails customers a unique code (that is specified by the manager) automatically when they buy a product. It will be used to email customers xbox live subscription numbers

 
Magento Community Magento Community
Magento Community
Magento Community
 
nate001
Jr. Member
 
Total Posts:  14
Joined:  2008-08-15
 

I haven’t used the event handler much, but I would start with a search to create a associated event, then send an auto email with a simple php script.

 
Magento Community Magento Community
Magento Community
Magento Community
 
team_in_medias
Sr. Member
 
Avatar
Total Posts:  113
Joined:  2008-05-06
Aachen, Germany
 

Hi Mongey,

we are sending license keys via invoice email in our shop.
I have done it by adding some PHP code to app\design\frontend\default\default\template\email\order\items\invoice\default.phtml because it is associated to a product. A custom attribute defines if a code should be sent with a product. The relevant code is as follows:

$_products Mage::getModel('catalog/product')->getCollection();
            
$_products->addAttributeToFilter('entity_id'$_item->getProductId());
            
$_products->addAttributeToSelect('send_license_key');
            
$_products->load();
            
            foreach(
$_products as $_product):
            
                
// check if product needs to send a license key with this email
                
if ($_product->getSendLicenseKey()):
                
[...]

It’s not the best code, it could be done in a module too, but it works fine. Generate your serial by some PHP function and output it in the following HTML.

HTH,
Andreas

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top