Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <global>
- <models>
- <sales>
- <rewrite>
- <order>MyModuleNameSpace_Mymodules_Model_Sales_Order</order>
- </rewrite>
- </sales>
- </models>
- </global>
- // Retrieve corresponding email template id and customer name
- if ($this->getCustomerIsGuest()) {
- $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $storeId);
- $customerName = $this->getBillingAddress()->getName();
- } else {
- $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE, $storeId);
- $customerName = $this->getCustomerName();
- }
- <?php
- class MyModuleNameSpace_Mymodules_Sales_Order extends Mage_Sales_Model_order
- {
- const XML_PATH_EMAI_SPECIAL_TEMPLATE = 'sales_email/order/special_template';
- public function queueNewOrderEmail($forceMode = false)
- {
- ......
- /* add this code */
- $items =$this-->getAllItems();
- $match=false;
- foreach ($items as $itemId => $item)
- {
- if( $item->getSku()=='YOUR_SPECIAL_PRODUCT'){
- $match=true;
- }
- }
- // Retrieve corresponding email template id and customer name
- /* this conditions */
- if($match){
- $templateId = Mage::getStoreConfig(self::XML_PATH_EMAI_SPECIAL_TEMPLATE, $storeId);
- $customerName = $this->getBillingAddress()->getName();
- }
- elseif($this->getCustomerIsGuest()) {
- /* change if to else if */
- //if ($this->getCustomerIsGuest()) {
- $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $storeId);
- $customerName = $this->getBillingAddress()->getName();
- } else {
- $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE, $storeId);
- $customerName = $this->getCustomerName();
- }
- ....
- return $this;
- }
- }
- if($match){
- $templateId = Mage::getStoreConfig(self::XML_PATH_EMAI_SPECIAL_TEMPLATE, $storeId);
- $customerName = $this->getBillingAddress()->getName();
- }
Add Comment
Please, Sign In to add comment