Jump to content

aveeva

Members
  • Posts

    89
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

aveeva's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. I am using Magento (Ver 1.9.x) If i try with my localhost success url like, http://192.168.1.65/magento/index.php/checkout/onepage/success/ and return success message with order id. if i try with live, success url like, https://abc.in/payubiz/redirect/success/ success page like blank page. How to solve the issue? Code : https://github.com/ZusZus/Payubiz
  2. There are lot of installation methods available, which one is best and help to upgrade future versions as well as extension. Centos 7, Nginx
  3. Thank you for your support. Thanks ☺️
  4. Finally done with below script : <?php class Gta_MerchantNotification_Model_Observer { public function merchantremainder($Observer) { $order = $Observer->getEvent()->getOrder(); $order_details = $order->getAllVisibleItems(); $itemData = array(); foreach ($order_details as $list) { $incrementid = $order->getIncrementId(); $sku = $list->getsku(); $name = $list->getName(); $price = $list->getPrice(); $Qty = $list->getQtyOrdered(); // $this->sendMailbasedOnSku($sku); $message = "<tr> <!-- <td>$incrementid</td> --> <td>$sku</td> <td>$name</td> <td>$price</td> <td>$Qty</td> </tr>"; $itemData[$list->getId()] = $message; } $finalMessage = "<p>Order Id : $incrementid</p> <table border='1'> <tr> <!-- <th>Id</th> --> <th>Sku</th> <th>Product name</th> <th>Price</th> <th>Qty Ordered</th> </tr>"; if (!empty($itemData)) { foreach ($itemData as $data) { $finalMessage .= $data; } $finalMessage .= "</table>"; // $this->sendMail($finalMessage); $this->sendMailbasedOnSku($finalMessage,$sku); } } public function sendMail($message) { $body = "$message"; $emailTemplate = Mage::getModel('core/email'); $emailTemplate->setFromName('Test mail'); $emailTemplate->setBody($body); $emailTemplate->setSubject("Custom Email from observer"); $emailTemplate->setType('html'); // $emailTemplate->setToEmail('[email protected]'); if($sku == '2') { $emailTemplate->setToEmail('[email protected]'); } elseif($sku == '3') { $emailTemplate->setToEmail('[email protected]'); } elseif($sku == '4') { $emailTemplate->setToEmail('[email protected]'); } else { $emailTemplate->setToEmail('[email protected]'); } $emailTemplate->send(); } public function sendMailbasedOnSku($message, $sku) { $body = "$message"; $emailTemplate = Mage::getModel('core/email'); $emailTemplate->setFromName('Giri Test mail'); $emailTemplate->setBody($body); $emailTemplate->setSubject("Custom Email from observer"); $emailTemplate->setType('html'); $chk_sku=(int)substr($sku, 0, 1); if($chk_sku == '2') { $emailTemplate->setToEmail('[email protected]'); } elseif($chk_sku == '3') { $emailTemplate->setToEmail('[email protected]'); } elseif($chk_sku == '4') { $emailTemplate->setToEmail('[email protected]'); } else{ $emailTemplate->setToEmail('[email protected]'); } return $emailTemplate->send(); // try{ // return $emailTemplate->send(); // Mage::getSingleton('core/session')->addSuccess('Success message'); // }catch (Exception $e) // { // Mage::getSingleton('core/session')->addError($e->getMessage()); // } } } ?> But few correction are there, how to solve below logic, eg: If an order contains, 2 series of sku and 3 series of sku order mail received only by 3 series of sku mail not received 2 series of sku mail. another eg. If order placed with 3 products, sku- 22 ([email protected]), sku - 33 ([email protected]), sku -44 ([email protected]) order received only [email protected] My condition, if the order contains 2 products means to send a separate mail. like 2 series of sku : 3 series of sku : 4 Series of sku : now order received highest value of sku,
  5. @Barand code : <?php class Gta_MerchantNotification_Model_Observer { public function merchantremainder($Observer) { $order = $Observer->getEvent()->getOrder(); $order_details = $order->getAllVisibleItems(); $itemData = array(); foreach ($order_details as $list) { $incrementid = $order->getIncrementId(); $sku = $list->getsku(); $name = $list->getName(); $price = $list->getPrice(); $Qty = $list->getQtyOrdered(); $this->sendMailbasedOnSku($sku); $message = "<tr> <!-- <td>$incrementid</td> --> <td>$sku</td> <td>$name</td> <td>$price</td> <td>$Qty</td> </tr>"; // $itemData[$list->getId()] = $message; $itemData[$orderNo][$skuFirst] = $message; } $finalMessage = "<p>Order Id : $incrementid</p> <table border='1'> <tr> <!-- <th>Id</th> --> <th>Sku</th> <th>Product name</th> <th>Price</th> <th>Qty Ordered</th> </tr>"; if (!empty($itemData)) { foreach ($itemData as $data) { $finalMessage .= $data; } $finalMessage .= "</table>"; $this->sendMailbasedOnSku($finalMessage); } } public function sendMailbasedOnSku($message) { $body = "$message"; $emailTemplate = Mage::getModel('core/email'); $emailTemplate->setFromName(' Test mail'); $emailTemplate->setBody($body); $emailTemplate->setSubject("Custom Email from observer"); $emailTemplate->setType('html'); $addys = [ 2 => '[email protected]', 3 => '[email protected]', 4 => '[email protected]' ]; // CHECK SKU FIRST DIGIT $chk_sku=(int)substr($sku, 0, 1); if($chk_sku == '2') { $sendTo = $addys[$chk_sku] ?? '[email protected]'; } elseif($chk_sku == '3') { $sendTo = $addys[$chk_sku] ?? '[email protected]'; } elseif($chk_sku == '4') { $sendTo = $addys[$chk_sku] ?? '[email protected]'; } else{ $emailTemplate->setToEmail('[email protected]'); } $emailTemplate->setToEmail($sendTo); return $emailTemplate->send(); } } ?> order not placed.
  6. getting error, <?php class Gta_MerchantNotification_Model_Observer { public function merchantremainder($Observer) { $order = $Observer->getEvent()->getOrder(); $order_details = $order->getAllVisibleItems(); $itemData = array(); foreach ($order_details as $list) { $incrementid = $order->getIncrementId(); $sku = $list->getsku(); $name = $list->getName(); $price = $list->getPrice(); $Qty = $list->getQtyOrdered(); $this->sendMailbasedOnSku($sku); $message = "<tr> <!-- <td>$incrementid</td> --> <td>$sku</td> <td>$name</td> <td>$price</td> <td>$Qty</td> </tr>"; // $itemData[$list->getId()] = $message; $itemData[$orderNo][$skuFirst] = $message; } $finalMessage = "<p>Order Id : $incrementid</p> <table border='1'> <tr> <!-- <th>Id</th> --> <th>Sku</th> <th>Product name</th> <th>Price</th> <th>Qty Ordered</th> </tr>"; if (!empty($itemData)) { foreach ($itemData as $data) { $finalMessage .= $data; } $finalMessage .= "</table>"; $this->sendMailbasedOnSku($finalMessage); } } public function sendMailbasedOnSku($message) { $body = "$message"; $emailTemplate = Mage::getModel('core/email'); $emailTemplate->setFromName('GIRI Test mail'); $emailTemplate->setBody($body); $emailTemplate->setSubject("Custom Email from observer"); $emailTemplate->setType('html'); $addys = [ 2 => '[email protected]', 3 => '[email protected]', 4 => '[email protected]' ]; // CHECK SKU FIRST DIGIT $chk_sku=(int)substr($sku, 0, 1); if($chk_sku == '2') { $sendTo = $addys[$chk_sku] ?? '[email protected]'; } elseif($chk_sku == '3') { $sendTo = $addys[$chk_sku] ?? '[email protected]'; } elseif($chk_sku == '4') { $sendTo = $addys[$chk_sku] ?? '[email protected]'; } else{ $emailTemplate->setToEmail('[email protected]'); } return $emailTemplate->send(); } } ?> Could you help me with above script.
  7. @Barand here i can see only one mail id, $chk_sku=substr($sku, 0, 1); $sendTo = $addys[$chk_sku] ?? '[email protected]'; How to add more than one mail id?
  8. @Barand Updated Code : <?php class Gta_MerchantNotification_Model_Observer { public function merchantremainder($Observer) { $order = $Observer->getEvent()->getOrder(); $order_details = $order->getAllVisibleItems(); $itemData = array(); foreach ($order_details as $list) { $incrementid = $order->getIncrementId(); $sku = $list->getsku(); $name = $list->getName(); $price = $list->getPrice(); $Qty = $list->getQtyOrdered(); $this->sendMailbasedOnSku($sku); $message = "<tr> <!-- <td>$incrementid</td> --> <td>$sku</td> <td>$name</td> <td>$price</td> <td>$Qty</td> </tr>"; $itemData[$list->getId()] = $message; } $finalMessage = " <p>Order Id : $incrementid</p> <table border='1'> <tr> <!-- <th>Id</th> --> <th>Sku</th> <th>Product name</th> <th>Price</th> <th>Qty Ordered</th> </tr>"; if (!empty($itemData)) { foreach ($itemData as $data) { $finalMessage .= $data; } $finalMessage .= "</table>"; $this->sendMailbasedOnSku($finalMessage); } } public function sendMailbasedOnSku($message) { $body = "$message"; $emailTemplate = Mage::getModel('core/email'); $emailTemplate->setFromName('Test mail'); $emailTemplate->setBody($body); $emailTemplate->setSubject("Custom Email from observer"); $emailTemplate->setType('html'); $chk_sku=(int)substr($sku, 0, 1); $emailTemplate = Mage::getModel('core/email'); if($chk_sku == '2') { $emailTemplate->setToEmail('[email protected]'); } elseif($chk_sku == '3') { $emailTemplate->setToEmail('[email protected]'); } elseif($chk_sku == '4') { $emailTemplate->setToEmail('[email protected]'); } else{ $emailTemplate->setToEmail('[email protected]'); } try{ $emailTemplate->send(); Mage::getSingleton('core/session')->addSuccess('Success message'); }catch (Exception $e) { Mage::getSingleton('core/session')->addError($e->getMessage()); } } } ?> Anything wrong?
  9. How to declare more than one mail id, $chk_sku=substr($sku, 0, 1); $sendTo = $addys[$chk_sku] ?? '[email protected]';
  10. Final code : <?php class Gta_MerchantNotification_Model_Observer { public function merchantremainder($Observer) { $order = $Observer->getEvent()->getOrder(); $order_details = $order->getAllVisibleItems(); $itemData = array(); foreach ($order_details as $list) { $incrementid = $order->getIncrementId(); $sku = $list->getsku(); $name = $list->getName(); $price = $list->getPrice(); $Qty = $list->getQtyOrdered(); $this->sendMailbasedOnSku($sku); $message = "<tr> <!-- <td>$incrementid</td> --> <td>$sku</td> <td>$name</td> <td>$price</td> <td>$Qty</td> </tr>"; $itemData[$list->getId()] = $message; } $finalMessage = " <p>Order Id : $incrementid</p> <table border='1'> <tr> <!-- <th>Id</th> --> <th>Sku</th> <th>Product name</th> <th>Price</th> <th>Qty Ordered</th> </tr>"; if (!empty($itemData)) { foreach ($itemData as $data) { $finalMessage .= $data; } $finalMessage .= "</table>"; $this->sendMail($finalMessage); } } public function sendMail($message) { $body = "$message"; $emailTemplate = Mage::getModel('core/email'); $emailTemplate->setFromName('Test mail'); $emailTemplate->setBody($body); $emailTemplate->setSubject("Custom Email from observer"); $emailTemplate->setType('html'); // $emailTemplate->setToEmail('[email protected]'); if($sku == '2') { $emailTemplate->setToEmail('[email protected]'); } elseif($sku == '3') { $emailTemplate->setToEmail('[email protected]'); } elseif($sku == '4') { $emailTemplate->setToEmail('[email protected]'); } else { $emailTemplate->setToEmail('[email protected]'); } $emailTemplate->send(); } public function sendMailbasedOnSku($sku) { $chk_sku=(int)substr($sku, 0, 1); $emailTemplate = Mage::getModel('core/email'); if($chk_sku == '2') { $emailTemplate->setToEmail('[email protected]'); } elseif($chk_sku == '3') { $emailTemplate->setToEmail('[email protected]'); } elseif($chk_sku == '4') { $emailTemplate->setToEmail('[email protected]'); } else{ $emailTemplate->setToEmail('[email protected]'); } try{ return $emailTemplate->send(); Mage::getSingleton('core/session')->addSuccess('Success message'); }catch (Exception $e) { Mage::getSingleton('core/session')->addError($e->getMessage()); } } } ?>
  11. @Barand After added $emailTemplate = Mage::getModel('core/email'); mail working, but if condition not working. As per my condition if sku start with 2 mail should go to [email protected] but here mail received [email protected] (Final email id in my if condition). How to correct my script?
  12. Any help with my error, Code : <?php class Gta_MerchantNotification_Model_Observer { public function merchantremainder($Observer) { $order = $Observer->getEvent()->getOrder(); $order_details = $order->getAllVisibleItems(); $itemData = array(); foreach ($order_details as $list) { $incrementid = $order->getIncrementId(); $sku = $list->getsku(); $name = $list->getName(); $price = $list->getPrice(); $Qty = $list->getQtyOrdered(); $this->sendMailbasedOnSku($sku); $message = "<tr> <!-- <td>$incrementid</td> --> <td>$sku</td> <td>$name</td> <td>$price</td> <td>$Qty</td> </tr>"; $itemData[$list->getId()] = $message; } $finalMessage = " <p>Order Id : $incrementid</p> <table border='1'> <tr> <!-- <th>Id</th> --> <th>Sku</th> <th>Product name</th> <th>Price</th> <th>Qty Ordered</th> </tr>"; if (!empty($itemData)) { foreach ($itemData as $data) { $finalMessage .= $data; } $finalMessage .= "</table>"; $this->sendMail($finalMessage); } } public function sendMail($message) { $body = "$message"; $emailTemplate = Mage::getModel('core/email'); $emailTemplate->setFromName('Test mail'); $emailTemplate->setBody($body); $emailTemplate->setSubject("Custom Email from observer"); $emailTemplate->setType('html'); // $emailTemplate->setToEmail('[email protected]'); if($sku == '2') { $emailTemplate->setToEmail('[email protected]'); } elseif($sku == '3') { $emailTemplate->setToEmail('[email protected]'); } elseif($sku == '4') { $emailTemplate->setToEmail('[email protected]'); } else { $emailTemplate->setToEmail('[email protected]'); } $emailTemplate->send(); } public function sendMailbasedOnSku($sku) { // sku is 22302 $chk_sku=(int)substr($sku, 0, 1); if($chk_sku == '2') { $emailTemplate->setToEmail('[email protected]'); } elseif($chk_sku == '3') { $emailTemplate->setToEmail('[email protected]'); } elseif($chk_sku == '4') { $emailTemplate->setToEmail('[email protected]'); } else{ $emailTemplate->setToEmail('[email protected]'); } try{ return $emailTemplate->send(); Mage::getSingleton('core/session')->addSuccess('Your request has been sent'); } catch (Exception $e) { Mage::getSingleton('core/session')->addError($e->getMessage()); } } } ?> error : [09-Jan-2020 04:53:42 UTC] PHP Fatal error: Uncaught Error: Call to a member function setToEmail() on null in C:\wamp64\www\magento\app\code\local\Gta\MerchantNotification\Model\Observer.php:99 Stack trace: #0 C:\wamp64\www\magento\app\code\local\Gta\MerchantNotification\Model\Observer.php(15): Gta_MerchantNotification_Model_Observer->sendMailbasedOnSku('22') #1 C:\wamp64\www\magento\app\code\core\Mage\Core\Model\App.php(1358): Gta_MerchantNotification_Model_Observer->merchantremainder(Object(Varien_Event_Observer)) #2 C:\wamp64\www\magento\app\code\core\Mage\Core\Model\App.php(1337): Mage_Core_Model_App->_callObserverMethod(Object(Gta_MerchantNotification_Model_Observer), 'merchantremaind...', Object(Varien_Event_Observer)) #3 C:\wamp64\www\magento\app\Mage.php(448): Mage_Core_Model_App->dispatchEvent('checkout_submit...', Array) #4 C:\wamp64\www\magento\app\code\core\Mage\Checkout\Model\Type\Onepage.php(872): Mage::dispatchEvent('checkout_submit...', Array) #5 C:\wamp64\www\magento\app\code\core\Mage\Checkout\controllers\OnepageController.php(579): M in C:\wamp64\www\magento\app\code\local\Gta\MerchantNotification\Model\Observer.php on line 99
  13. PHP mail function how to set recipient mail id based on if condition?
  14. I am using magento for sending mail with condition, My code: <?php class Gta_MerchantNotification_Model_Observer { public function merchantremainder($Observer) { $order = $Observer->getEvent()->getOrder(); $order_details = $order->getAllVisibleItems(); $itemData = array(); foreach ($order_details as $list) { $incrementid = $order->getIncrementId(); $sku = $list->getsku(); $name = $list->getName(); $price = $list->getPrice(); $Qty = $list->getQtyOrdered(); $extra = $order->getIncrementId(); $message = " <tr> <!-- <td>$incrementid</td> --> <td>$sku</td> <td>$name</td> <td>$price</td> <td>$Qty</td> </tr>"; $itemData[$list->getId()] = $message; } $finalMessage = " <p>Order Id : $incrementid</p> <table border='1'> <tr> <!-- <th>Id</th> --> <th>Sku</th> <th>Product name</th> <th>Price</th> <th>Qty Ordered</th> </tr>"; if (!empty($itemData)) { foreach ($itemData as $data) { $finalMessage .= $data; } $finalMessage .= "</table>"; $this->sendMail($finalMessage); } } public function sendMail($message) { $body ="$message"; $emailTemplate = Mage::getModel('core/email'); $emailTemplate->setFromName('abc'); $emailTemplate->setBody($body); $emailTemplate->setSubject("Custom Email from observer"); $emailTemplate->setType('html'); $emailTemplate->setToEmail('[email protected]'); $emailTemplate->send(); } } ?> Output : If order placed mail send to [email protected]. How to set email sender based on SKU $sku from order. I want : 1) If SKU starts with 2, email should go to the mail id [email protected], screenshot : 2) If SKU starts with 3, email should go to the mail id [email protected], screenshot : 3) If SKU starts with 4, email should go to the mail id [email protected], screenshot : FYI - If an order contains 10 items email should go separately based on SKU. But an order id the same must include all the emails.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.