Exemplo n.º 1
0
 /**
  * Prepare shipping info as html
  *
  * @param Fooman_PdfCustomiser_Helper_Pdf $helper
  * @param                                 $order
  * @param                                 $printItem
  *
  * @return string
  */
 public function PrepareShipping(Fooman_PdfCustomiser_Helper_Pdf $helper, $order, $printItem)
 {
     if (!$order->getIsVirtual()) {
         //display depending on if Total Weight should be displayed or not
         $totalWeight = false;
         if ($helper->displayWeight()) {
             //calculate weight
             $totalWeight = 0;
             foreach ($printItem->getAllItems() as $item) {
                 if ($printItem instanceof Mage_Sales_Model_Order) {
                     $totalWeight += $item->getQtyOrdered() * $item->getWeight();
                 } else {
                     $totalWeight += $item->getQty() * $item->getOrderItem()->getWeight();
                 }
             }
         }
         $block = Mage::app()->getLayout()->createBlock('pdfcustomiser/pdf_block', 'pdfcustomiser.shipping');
         $html = $block->setPdfHelper($helper)->setTracks($order->getTracksCollection())->setShippingDescription($this->_fixEncoding($order->getShippingDescription()))->setTotalWeight($totalWeight)->setTemplate('fooman/pdfcustomiser/shipping.phtml')->toHtml();
         $processor = Mage::helper('cms')->getBlockTemplateProcessor();
         $processor->setVariables(array('order' => $order, 'sales_object' => $helper->getSalesObject()));
         $html = $processor->filter($html);
         return $html;
     } else {
         return '';
     }
 }