Whats new?

Last modified by cauldronic on Fri, November 26, 2010 05:35
Source|Old Revisions  

In this version, added a line for displaying utf-8 encodings properly. And recovered the telephone line which is dropped from the shipping address field on the previous version.

A quick fix to add a pop up print label print window in the orders page. Uses the default admin template, so you need to refresh on Magento upgrade. Have left red css border so you can use to position the label. EDITORS PLEASE NOTE: if you edit this make sure to use 3 backslashes to get one output when using before the “n” character in code section.

Edit info.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>

<script type="text/javascript">
/* <![CDATA[ */
<?php

$shipaddr= $_order->getShippingAddress()->getFormated(true);

// note the next line should show a backslash n in the explode function
// this backslash can get lost when editing the Wiki
$splitx=explode("n",$shipaddr);

$inx=array('<br />','<br/>',' ');
$outx=array('','','%20');

$shipx='';

foreach($splitx as $sx):
if(!empty($sx)):
$shipx.=str_replace($inx,$outx,$sx).'@@';
endif;
endforeach;

echo 'var shipx="'.urldecode($shipx).'"; ';?>

var popUpWin=0;

function labelPrint() {
var url="/print_label?addr="+shipx;

popUpWin = open(url,'popUpWin','toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,copyhistory=yes, width=600,height=220,left=200,top=200,screenX=200,screenY=200');
}

</script> 
 
add CMS entry

Create a page with no layout and with the URL identifier print_label

then edit the CMS page adding this code

<style type="text/css" media="all">
* { margin:0; padding:0; }
#address {
/**********ADJUST THE CSS VALUES BELOW FOR THE PRINT LABEL PAGE ***********/ 

font-size:17pt;
top:30px;
left:20px; 
width:400px;
height:210px; 
line-height:120%;
border:1px solid red; 

/**************************************************************/
font-weight:bold;
position:absolute;
}
#printBTN { float:right;margin:2px 5px 0 0 !important;}</style>

<style type="text/css" media="print"> #printBTN {visibility:hidden;}</style>

<div id="printBTN"><input type="button" onClick="window.print()" value="Print" /></div>

<div id="address">
<script type="text/javascript">
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>


Corrected: Link “Print” to call function was missing. Has been put back.




 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs