Whats new?
This is an old revision of the document!
A quick fix to add a pop up print label print window in the orders page. Thought it might be useful for someone. This uses the default admin template, so you would need to refresh on Magento upgrade. Have left red border so you can use to position the label.
Edit view.phtml |
Download the file /app/design/adminhtml/default/default/template/sales/order/view/info.phtml
Around line 171 of this file, just after Shipping Address Title <h4 class=”icon-head head-shipping-address”><?php echo Mage::helper(’sales’)→__(’Shipping Address’) ?></h4>
add this
<span style="float:right"><a href='#' style="color:#FFCC22" onclick="labelPrint()" >Print Shipping Label</a></span>
at the bottom of file add this:
<script type="text/javascript"> /* <![CDATA[ */ <?php $shipaddr= $_order->getShippingAddress()->getFormated(true); $splitx=explode("n",$shipaddr); $inx=array('<br />','<br/>',' '); $outx=array('','',''); $shipx=''; foreach($splitx as $sx): if(!empty($sx) && substr($sx,0,3)!='T: '): $shipx.=str_replace($inx,$outx,$sx).'@@'; endif; endforeach; echo "n".'var shipx="'.$shipx.'"; '."n" ; ?> var popUpWin=0; function labelPrint() { var url='/label.html?addr='+shipx; // popUpWin = open(url,'popUpWin','toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,copyhistory=yes, width=500,height=250,left=100,top=100,screenX=100,screenY=100'); } /* ]]> */ </script>
Create label.html |
then create file label html and upload to Magento web root folder.
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Print Shipping Label</title> <style type="text/css" media="all"> * { margin:0; padding:0; } #address { font-size:17px; line-height:120%; font-weight:bold;position:absolute; top:30px;left:20px; width:450px; height:190px; border:1px solid red; } #printBTN { float:right;margin:2px 5px 0 0 !important; } </style> <style type="text/css" media="print"> #printBTN {visibility:hidden;} </style> </head> <body> <div id="printBTN"><input type="button" value="Print" onClick="window.print()" /></div> <div id='address'> <script type="text/javascript"> /* <![CDATA[ */ var str=location.href; var output=''; str=str.substr(str.indexOf("addr=")+5); str=str.replace(/%20/g,' '); output=str.replace(/@@/g, "<br />"); document.write(output); /* ]]> */ </script> </div></body></html>
You can then just adjust the popup label.html to size and position on printing.


