C:\xampp\htdocs\m1\app\etc\modules\Maddy_Custompdf.xml
<?xml version="1.0"?>
<config>
<modules>
<Maddy_Custompdf>
<active>true</active>
<codePool>local</codePool>
</Maddy_Custompdf>
</modules>
</config>
C:\xampp\htdocs\m1\app\code\local\Maddy\Custompdf\IndexController.php
<?php
class Maddy_Custompdf_IndexController extends Mage_Core_Controller_Front_Action {
public function invoicesAction() {
$orderId = (int) $this->getRequest()->getParam('order_id');
$order = Mage::getModel('sales/order')->load($orderId);
if ($this->_canViewOrder($order)) {
$invoices = Mage::getResourceModel('sales/order_invoice_collection')
->setOrderFilter($order->getId())
->load();
if ($invoices->getSize() > 0) {
$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoices);
return $this->_prepareDownloadResponse(
'invoice'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(),
'application/pdf'
);
}
}
}
protected function _canViewOrder($order)
{
$customerId = Mage::getSingleton('customer/session')->getCustomerId();
$availableStates = Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates();
if ($order->getId() && $order->getCustomerId() && ($order->getCustomerId() == $customerId)
&& in_array($order->getState(), $availableStates, $strict = true)
) {
return true;
}
return false;
}
}
C:\xampp\htdocs\m1\app\code\local\Maddy\Custompdf\etc\config.xml
<?xml version="1.0"?>
<config>
<modules>
<Maddy_Custompdf>
<version>0.1.0</version>
</Maddy_Custompdf>
</modules>
<frontend>
<routers>
<custompdf>
<use>standard</use>
<args>
<module>Maddy_Custompdf</module>
<frontName>custompdf</frontName>
</args>
</custompdf>
</routers>
<layout>
<updates>
<custombrand>
<file>custombrand.xml</file>
</custombrand>
</updates>
</layout>
</frontend>
</config>
C:\xampp\htdocs\m1\app\design\frontend\base\default\template\sales\order\history.php
Add this line on line # 63 around below Reorder.
<strong><a href="<?php echo $this->getUrl('custompdf/index/invoices', array('order_id' => $_order->getId())) ?>">Print Invoices</a></strong>
It will surely Help.