Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Custom Email depending on Category of Product
 
sei
Member
 
Total Posts:  35
Joined:  2008-08-13
 

I was wondering if anybody knew if it was possible to send a custom email depending on the category the product belongs to.
We need to somehow figure out how to send an additional set of instructions to the customer depending on the product chosen along with the invoice etc etc.

Has anybody heard of this done in magento?

Thanks ahead for any help.

 
Magento Community Magento Community
Magento Community
Magento Community
 
sei
Member
 
Total Posts:  35
Joined:  2008-08-13
 

lil bumps

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

Hello sei,

we are sending custom emails based on a custom attribute of products. If you want to base it on the category, it should be quite similar. Or you can instead use a custom attribute yourself, I don’t know if this is possible for your needs.

We are using the event checkout_onepage_controller_success_action to observe checkouts. Within the function which gets run on checkout, we are checking all products and, if the attribute is not empty, an email gets sent.

The config values are defined in a system.xml file.
You will need to create a new transactional email in the backend which will be chosen in the config area.

The relevant part in the model is the following:

const XML_PATH_SINGULARVOUCHERS_EMAIL_TEMPLATE 'admin/singularvouchers/email_template';
    const 
XML_PATH_SINGULARVOUCHERS_EMAIL_IDENTITY 'admin/singularvouchers/email_identity';
[...]
    
public function send_voucher($observer)
    
{
            $orderId 
Mage::getSingleton('checkout/type_onepage')
                ->
getCheckout()->getLastOrderId();
            
$order Mage::getModel('sales/order')->load($orderId); 
            
            
$items $order->getAllItems();
            foreach(
$items as $item{
            
                $productId 
$item->getProductId();
                
$product Mage::getModel('catalog/product')->load($productId);

                
// retrieve custom attribute "vouchers" from all products
                
$voucher_codes $product->getData('vouchers');
                    
                if (
$voucher_codes != ''{

                    
// prepare and send email
                    
$translate Mage::getSingleton('core/translate');
                    
/* @var $translate Mage_Core_Model_Translate */
                    
$translate->setTranslateInline(false);
            
                    
Mage::getModel('core/email_template')
                        ->
setDesignConfig(array('area'=>'frontend''store'=>$storeId))
                        ->
sendTransactional(
                            
Mage::getStoreConfig(self::XML_PATH_SINGULARVOUCHERS_EMAIL_TEMPLATE),
                            
Mage::getStoreConfig(self::XML_PATH_SINGULARVOUCHERS_EMAIL_IDENTITY),
                            
$customer->getEmail(),
                            
$customer->getName(),
                            array(
'voucher_codes' => $voucher_codes)
                        );
                    
$translate->setTranslateInline(true);
                
                
}
            }
    }

You find the complete module attached.

HTH,
Andreas

File Attachments
SingularVouchers.zip  (File Size: 2KB - Downloads: 78)
 
Magento Community Magento Community
Magento Community
Magento Community
 
auslaw
Jr. Member
 
Total Posts:  12
Joined:  2009-04-19
 

I have set up the Singular Voucher module. However it doesnt seem to work. It just displays a blank page after a successful checkout. Any suggestions?

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