Step 1:
Open the file:
app/design/adminhtml/default/default/template/sales/order/view/info.phtml
Around line 170, after
<h4><?php echo Mage::helper(‘sales’)->__(‘Shipping Address’) ?></h4>
put the following code:
Landscape Portrait Print Label:
Step 2:
Place at the bottom of the file, the following code:
<script type="text/javascript"> <?php $shipaddr= trim($_order->getShippingAddress()->getFormated(true)); $splitx=explode("\n",$shipaddr); $end = ""; $end = Mage::getBaseUrl(); echo "\n".'var end="'.$end.'"; '."\n" ; echo"\n".'var shipx="'.urlencode($shipaddr).'"; '."\n" ; ?> var popUpWin; function labelPrintLandscape() { var url=end.replace("index.php/admin/","").replace("index.php/",""); url=url +"custom/print_label_landscape.php?addr="+shipx; popUpWin = open(url,'popUpWin','toolbar=yes,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,copyhistory=yes, width=500,height=300,left=100,top=100,screenX=100,screenY=100'); } function labelPrintPortrait() { var url=end.replace("index.php/admin/","").replace("index.php/",""); url=url +"custom/print_label_portrait.php?addr="+shipx; popUpWin = open(url,'popUpWin','toolbar=yes,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,copyhistory=yes, width=500,height=300,left=100,top=100,screenX=100,screenY=100'); } </script>
Step:3
Create the directories /custom and /custom/dompdf on the site root folder.
Download the dompdf library here and extract its contents to /custom/dompdf.
Step:4
Create the file /custom/print_label_portrait.php and with the following content:
<?php $html ='<html<head></head><body>'; $url = str_replace("addr=","",$_SERVER["QUERY_STRING"]); $decoded_url = urldecode($url); //REMOVE PHONE NUMBER //$decoded_url = explode("T:",$decoded_url); $decoded_url = $decoded_url[0]; $html = utf8_decode(str_replace("T:","",urldecode($decoded_url))); $html.="</body></html>"; require_once("dompdf/dompdf_config.inc.php"); $dompdf = new DOMPDF(); $dompdf->load_html($html); $paper = array(0,0,152.82,285.83); $dompdf->set_paper($paper , 'portrait'); $dompdf->render(); $dompdf->stream("label_landscape.pdf"); ?>
Step:5
Create the file /custom/print_label_landscape.php and with the following content:
<?php $html ='<html<head></head><body>'; $url = str_replace("addr=","",$_SERVER["QUERY_STRING"]); $decoded_url = urldecode($url); //REMOVE PHONE NUMBER //$decoded_url = explode("T:",$decoded_url); $decoded_url = $decoded_url[0]; $html = utf8_decode(str_replace("T:"," ",urldecode($decoded_url))); $html.="</body></html>"; require_once("dompdf/dompdf_config.inc.php"); $dompdf = new DOMPDF(); $dompdf->load_html($html); $paper = array(0,0,152.82,285.83); $dompdf->set_paper($paper , 'landscape'); $dompdf->render(); $dompdf->stream("label_landscape.pdf"); ?>
Now everything finished. In the administration page, go to a order page and you should see two links in the address box header, clicking in one of the should generate the label.
hope it Helps.Thanks...