Reputation: 119
I need to call the invoice number and customer email on magento success.phtml grammatically.
I need this for pre-populated email for resellerrating exit survey code.
<link rel="stylesheet" href="https://www.resellerratings.com/images
/js/dhtml_survey.css" type="text/css" />
<script type="text/javascript">
seller_id = XXXX;
inv = "B5000";
email_pass = "[email protected]";
document.write('<'+ 'script type="text/javascript" src="https://www.resellerratings.com/images/js/popup_include.js"><\/script>');
</script>
I know how to call the order ID and Grandtotal:
$order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
$amount = number_format($order->getGrandTotal(),2);
I found this code somewhere on magento forums, but have no idea how to call out the invoice number and customer email for resellerratings. Help me out with this please.
Regards, Jon
Upvotes: 0
Views: 1273
Reputation: 4980
First, add an event observer code in your module config.xml /your_module/etc/config.xml,
<global>
<events>
<sales_order_invoice_save_after>
<observers>
<your_module>
<type>singleton</type>
<class>your_module/observer</class>
<method>sales_order_invoice_save_after</method>
</your_module>
</observers>
</sales_order_invoice_save_after>
</events>
</global>
then, add an event observer in your Observer.php
/your_module/model/Observer.php
Class NameSpace_Module_Model_Observer()
{
public function sales_order_invoice_save_after($observer)
// here should be save_after because invoice id not available until the object has been saved that means an order
{
$invoice = $observer->getEvent()->getInvoice();
// to see what variables available in $invoice, use the following
// echo "<pre>"; print_r($invoice->getData()); exit;
}
}
Upvotes: 1
Reputation: 6919
$customer = Mage::getSingleton('customer/session')->getCustomer();
Will have a lot of data you need about the current customer.
Re: Invoicing: are you generating invoices as the orders are placed?
An order can have multiple invoices, and multiple invoice IDs.
Check out this post for an example of how to get the Invoice IDs: http://www.magentocommerce.com/boards/viewthread/198222/#t313532
Upvotes: 1