Skip to content
This repository has been archived by the owner on Aug 10, 2020. It is now read-only.

Change how invoice email is done to an observer event #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions src/app/code/community/Fontis/EwayAu/Model/Direct.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,26 +374,4 @@ public function parseXmlResponse($xmlResponse)

return $newResArr;
}

/**
* Check if invoice email can be sent, and send it
*
* @param Mage_Sales_Model_Order_Invoice $invoice
* @param Mage_Sales_Model_Order_Payment $payment
* @return Fontis_EwayAu_Model_Direct
*/
public function processInvoice($invoice, $payment)
{
parent::processInvoice($invoice, $payment);
try {
$storeId = $invoice->getOrder()->getStoreId();
if (Mage::helper('sales')->canSendNewInvoiceEmail($storeId)) {
$invoice->save();
$invoice->sendEmail();
}
} catch (Exception $e) {
mage::logException($e);
}
return $this;
}
}
54 changes: 54 additions & 0 deletions src/app/code/community/Fontis/EwayAu/Model/Observer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

/**
* Fontis eWAY Australia payment gateway
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so you can be sent a copy immediately.
*
* Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
*
* @category Fontis
* @package Fontis_EwayAu
* @copyright Copyright (c) 2010 Fontis (http://www.fontis.com.au)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/**
* Observer to handle invoice email sending after payment was completed
*
* @author Lucas van Staden ([email protected])
* */
class Fontis_EwayAu_Model_Observer {

/**
* Email invoice when all order objects have been completed
*
* @param type $observer
*/
public function checkout_submit_all_after($observer) {
$order = $observer->getOrder();
if ($order->hasInvoices()) {
foreach ($order->getInvoiceCollection() as $invoice) {
// email out the invoices
try {
$storeId = $invoice->getOrder()->getStoreId();
if (Mage::helper('sales')->canSendNewInvoiceEmail($storeId)) {
$invoice->sendEmail();
}
} catch (Exception $e) {
mage::logException($e);
}
}
}
return $this;
}

}
11 changes: 11 additions & 0 deletions src/app/code/community/Fontis/EwayAu/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@
</types>
</cc>
</payment>
<events>
<checkout_submit_all_after>
<observers>
<ewayau_checkout_submit_all_after>
<type>singleton</type>
<class>ewayau/observer</class>
<method>checkout_submit_all_after</method>
</ewayau_checkout_submit_all_after>
</observers>
</checkout_submit_all_after>
</events>
</global>
<frontend>
<secure_url>
Expand Down