Guest User

Untitled

a guest
Apr 20th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. <global>
  2. <models>
  3. <sales>
  4. <rewrite>
  5. <order>MyModuleNameSpace_Mymodules_Model_Sales_Order</order>
  6. </rewrite>
  7. </sales>
  8. </models>
  9. </global>
  10.  
  11. // Retrieve corresponding email template id and customer name
  12. if ($this->getCustomerIsGuest()) {
  13. $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $storeId);
  14. $customerName = $this->getBillingAddress()->getName();
  15. } else {
  16. $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE, $storeId);
  17. $customerName = $this->getCustomerName();
  18. }
  19.  
  20. <?php
  21. class MyModuleNameSpace_Mymodules_Sales_Order extends Mage_Sales_Model_order
  22. {
  23. const XML_PATH_EMAI_SPECIAL_TEMPLATE = 'sales_email/order/special_template';
  24.  
  25.  
  26. public function queueNewOrderEmail($forceMode = false)
  27. {
  28. ......
  29. /* add this code */
  30. $items =$this-->getAllItems();
  31. $match=false;
  32. foreach ($items as $itemId => $item)
  33. {
  34. if( $item->getSku()=='YOUR_SPECIAL_PRODUCT'){
  35. $match=true;
  36. }
  37.  
  38. }
  39.  
  40.  
  41. // Retrieve corresponding email template id and customer name
  42. /* this conditions */
  43. if($match){
  44. $templateId = Mage::getStoreConfig(self::XML_PATH_EMAI_SPECIAL_TEMPLATE, $storeId);
  45. $customerName = $this->getBillingAddress()->getName();
  46.  
  47. }
  48. elseif($this->getCustomerIsGuest()) {
  49. /* change if to else if */
  50. //if ($this->getCustomerIsGuest()) {
  51. $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $storeId);
  52. $customerName = $this->getBillingAddress()->getName();
  53. } else {
  54. $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE, $storeId);
  55. $customerName = $this->getCustomerName();
  56. }
  57.  
  58. ....
  59.  
  60. return $this;
  61. }
  62.  
  63.  
  64.  
  65. }
  66.  
  67. if($match){
  68. $templateId = Mage::getStoreConfig(self::XML_PATH_EMAI_SPECIAL_TEMPLATE, $storeId);
  69. $customerName = $this->getBillingAddress()->getName();
  70.  
  71. }
Add Comment
Please, Sign In to add comment