I have two root categories in my magento site. One is \"Home Products\" and the other is \"Office products\".
These two root categories have some sub categories also.
I suggest you to write own Observer to order.
sales_order_place_after
event suits best for your purpose.
If buyer can add to shopping cart items only from 1 cateogry.
Your module should:
Send email
public function sendOrder(){
$order = $observer->getEvent()->getOrder();
...
//Implement logic here
...
$emailTemplate = Mage::getModel('core/email_template')
->loadDefault('your_template');
$emailTemplateVariables = array();
$emailTemplateVariables['order'] = $order;
$emailTemplate->setSenderName('Your shops name');
$emailTemplate->setSenderEmail('addres@from.com');
$emailTemplate->setTemplateSubject(Subject');
$emailTemplate->send('to@addres.com','Name', $emailTemplateVariables);
}
Update 1
First of all I insist that you see the link I provide in the comments area.
Then: To create module:
Create in app/etc/modules/ Company_Module.xml file. With the content similiar to this one:
true local This eill tell magento, that in app/code/local/Company/Module there is something interesting to watch.
Create proper folder and file structure. For you module I think it would be enough:
Company
-Module
--etc
---config.xml
--Model
---Observer.php
--Helper
---Data.php
config.xml:
<?xml version="1.0"?>
<config>
<modules>
<Company_Module>
<version>0.1.0</version>
</Company_Module>
</modules>
<global>
<models>
<company_module>
<class>Company_Module_Model</class>
</company_module>
</models>
<helpers>
<cmod>
<class>Company_Module_Helper</class>
</cmod>
</helpers>
<events>
<sales_order_place_after>
<observers>
<sales_order_place_after_observer>
<class>company_module/observer</class>
<method>handleOrder</method>
</sales_order_place_after_observer>
</observers>
</sales_order_place_after>
</events>
</global>
</config>
Data.php - It is empty but it should be.
class Company_Module_Helper_Data extends Mage_Core_Helper_Abstract{
}
Observer.php
class Company_Module_Model_Observer{
public function handleOrder($observer){
$order = $observer->getEvent()->getOrder();
...
//Implement logic here
...
$emailTemplate = Mage::getModel('core/email_template')
->loadDefault('your_template');
$emailTemplateVariables = array();
$emailTemplateVariables['order'] = $order;
$emailTemplate->setSenderName('Your shops name');
$emailTemplate->setSenderEmail('addres@from.com');
$emailTemplate->setTemplateSubject(Subject');
$emailTemplate->send('to@addres.com','Name', $emailTemplateVariables);
}
}
@Jevgeni (and anyone else needing the link), the Link for Magento has moved
http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method