如何在打印出来的Pdf里面增加额外信息,其实只要知道如何操纵数据,最终打印的handle还是Zend来执行,Magento内置了Zend_Pdf类,用他来打印PDF文件,下面是一个示例,比较简单易懂,在此抛砖引玉。以下代码加在Mage_Sales_Model_Order_Pdf_Invoice这个类中。
/* Gfit Msg Notice */
$freegiftboxHandle = "Free gift box set";
$freestandardHandle = "Free gift box set and Free Standard Shipping";
$freeDHLHandle = "Free gift box set & DHL shipping & Free Gift";
//$payPrice = $this->helper('checkout')->formatPrice(Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal());;
$_totalData = $order->getData();
$_grand = $_totalData['grand_total'];
$payPrice = $_grand;
if($payPrice>65&&$payPrice<160){
$additionalGift = $freegiftboxHandle;
}
if($payPrice>160&&$payPrice<200){
$additionalGift = $freestandardHandle;
}
if($payPrice>=200){
$additionalGift = $freeDHLHandle;
}
$page->drawText(Mage::helper('sales')->__('Additonal Gift: ') . $additionalGift, 250, 780, 'UTF-8');
/* end of Gift Msg Notice */
附上效果,带额外信息还有带图打印,大家可以琢磨下,迟些做个高级打印模块出来供大家参考:
That's all ! Enjoy it~