Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Search
Search


Forum Index » Templates

Post new topic   Reply to topic
v3 Avery Like Plain Shipping Label, NO return address
View previous topic :: View next topic  
Author Message
Brett Berger
Site Admin


Joined: 11 Jun 2010
Posts: 2455

PostPosted: Mon Aug 22, 2011 6:42 pm    Post subject: v3 Avery Like Plain Shipping Label, NO return address Reply with quote

In ShipWorks v3 > Click Manage > Templates > Create New > Provide an applicable name > choose Labels > choose HTML > Edit > Delete ALL code in the template and replace with below code..


Code:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:sw="http://www.interapptive.com/shipworks" extension-element-prefixes="sw">
<xsl:output method="html" encoding="utf-8" indent="yes" />

<!--                                                            -->
<!-- Start of processing                                        -->
<!--                                                            -->
<xsl:template match="/">

<html>
     
<head>

<style>
    #labelcontent
    {
        white-space: nowrap;
        padding: 8px;
        border: 0;
        width: 100%; height 100%;
        font: 8pt Arial;
    }
   
    #labelcontent .contactName
    {
        font-weight: bold;
        font-size: 10pt;
    }
</style>

</head>

<body>

    <xsl:variable name="address">
        <xsl:call-template name="selectLabelAddress" />
    </xsl:variable>
       
    <div id="labelcontent">
        <xsl:call-template name="formatAddress">
            <xsl:with-param name="address" select="msxsl:node-set($address)/*" />
        </xsl:call-template>
    </div>
       
   
</body>
</html>

</xsl:template>
<xsl:template name="formatAddress">
    <xsl:param name="address" />
   
    <xsl:if test="$address/FirstName != '' or $address/LastName != ''">
        <span class="contactName">
            <xsl:value-of select="$address/FirstName" />
                <xsl:text> </xsl:text>
            <xsl:value-of select="$address/LastName" />
        </span>
        <br />
    </xsl:if>

    <xsl:if test="$address/Company != ''">
        <span class="companyName"><xsl:value-of select="$address/Company" /></span>
        <br />
    </xsl:if>

   <xsl:value-of select="$address/Line1" />
    <br />
   
    <xsl:if test="$address/Line2 != ''">
        <xsl:value-of select="$address/Line2" />
        <br />
    </xsl:if>
   
    <xsl:value-of select="$address/City" />,
    <xsl:value-of select="$address/StateName" /><xsl:text> </xsl:text>
    <xsl:value-of select="$address/PostalCode" />
    <br />

    <xsl:if test="$address/CountryCode != 'US'">
        <xsl:value-of select="$address/CountryName" />
        <br />
    </xsl:if>

   
</xsl:template>

<!--                                                                        -->
<!-- Selects the shipping label address to use based on the current context -->
<!--                                                                        -->
<xsl:template name="selectLabelAddress">
    <xsl:if test="//Context = 'Customer'">
        <xsl:copy-of select="//Customer[1]/Address[@type='ship']" />
    </xsl:if>
    <xsl:if test="//Context = 'Order'">
        <xsl:copy-of select="//Order[1]/Address[@type='ship']" />
    </xsl:if>
    <xsl:if test="//Context = 'Shipment'">
        <xsl:copy-of select="//Shipment[1]/Address[@type='ship']" />
    </xsl:if>
</xsl:template>

<!--                                                            -->
<!-- Outputs a table with the standard Ship To \ Bill To info   -->
<!--                                                            -->
<xsl:template name="outputShipToBillTo">
    <xsl:param name="order" />
   
        <xsl:variable name="showAddress" select="//StoreType != 'eBay' or $order/eBay/CheckoutComplete = 'true'" />
      
        <table id="addressInfo" cellspacing="0">
       
        <tr>
         <td style="width: 47.5%;">
           
            <table id="shipaddress" style="width: 100%;" cellspacing="0">
               <tr>
                  <td class="header">
                     Ship To
                  </td>
               </tr>
               
               <tr>
                  <td>
                       <xsl:if test="$showAddress">
                                <xsl:call-template name="formatAddress">
                                    <xsl:with-param name="address" select="$order/Address[@type='ship']" />
                                </xsl:call-template>
                       </xsl:if>
                           
                       <xsl:if test="not($showAddress)">
                          <font color="#FF0000"><b>Checkout incomplete.</b></font><br />
                          Winning Buyer: <xsl:value-of select="$order/eBay/BuyerID" />
                       </xsl:if>
                        </td>
               </tr>
            </table>
                                                
         </td>
         
         
         <td style="width: 5%; border:0"> </td>
         
         <td id="billaddress" style="width: 47.5%;">
            <table style="width: 100%;" cellspacing="0">
               <tr>
                  <td class="header">
                     Bill To
                  </td>
               </tr>
               
               <tr>
                  <td>
                       <xsl:if test="$showAddress">
                                <xsl:call-template name="formatAddress">
                                    <xsl:with-param name="address" select="$order/Address[@type='bill']" />
                                </xsl:call-template>
                       </xsl:if>
                        </td>
                    </tr>
            </table>
         </td>
      </tr>
   </table>
           
</xsl:template>

<!--                                                            -->
<!-- Outputs a table with all order items and options           -->
<!--                                                            -->
<xsl:template name="outputOrderDetails">
    <xsl:param name="order" />
    <xsl:param name="showAmounts" select="true()" />
    <xsl:param name="showThumbnails" select="false()" />

   <table id="orderdetails" cellspacing="0">
   
      <tr class="header">
            <xsl:if test="$showThumbnails">
                <td style="width: 50px;">Image</td>
            </xsl:if>
         <td style="width: 20%;">Item #</td>
         <td>Name</td>
         <td align="right">QTY</td>
            <xsl:if test="$showAmounts">
             <td align="right">Price</td>
             <td align="right">Total</td>
            </xsl:if>
      </tr>

      <xsl:for-each select="$order/Item">
         <tr class="orderitem">
                <xsl:if test="$showThumbnails">
                    <td>                     
                        <xsl:if test="Thumbnail != ''">
                     <img src="{Thumbnail}" alt="" style="height:50; width:50; border:0;" />
                  </xsl:if>
                    </td>
                </xsl:if>
            <td>
                    <xsl:if test="//StoreType = 'eBay'">
                        <a href="http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&amp;item={Code}"><xsl:value-of select="Code" /></a>
                    </xsl:if>   
                    <xsl:if test="//StoreType != 'eBay'">
                        <xsl:value-of select="Code" />
                    </xsl:if>
                </td>
            <td><xsl:value-of select="Name" /></td>
            <td align="right"><xsl:value-of select="Quantity" /></td>
                <xsl:if test="$showAmounts">
                <td align="right"><xsl:value-of select="format-number(UnitPrice, '#,##0.00')" /></td>
                <td align="right"><xsl:value-of select="format-number(UnitPrice * Quantity, '#,##0.00')" /></td>
                </xsl:if>
            </tr>
         
         <xsl:for-each select="Option">
            <tr class="itemoption">
                    <xsl:if test="$showThumbnails">
                        <td></td>
                    </xsl:if>
               <td></td>
               <td>
                  <table class="itemoptionname" style="width: 100%;" cellspacing="0">
                     <tr>
                        <td nowrap="nowrap"><xsl:value-of select="Name" />: </td>
                        <td style="width: 100%;"><xsl:value-of select="Description" /></td>
                     </tr>
                  </table>
                </td>
                    <td></td>
                    <xsl:if test="$showAmounts">
                        <xsl:if test="UnitPrice != 0">
                   <td align="right"><xsl:value-of select="format-number(UnitPrice, '#,##0.00')" /></td>
                   <td align="right"><xsl:value-of select="format-number(UnitPrice * ../Quantity, '#,##0.00')" /></td>
                        </xsl:if>
                        <xsl:if test="UnitPrice = 0">
                            <td></td>
                            <td></td>
                        </xsl:if>
                    </xsl:if>
            </tr>
         </xsl:for-each>
      </xsl:for-each>
       
   </table>           
       
</xsl:template>

<!--                                                            -->
<!-- Outputs a table with all charges and totals                -->
<!--                                                            -->
<xsl:template name="outputOrderTotals">
    <xsl:param name="order" />
   
    <table id="totals" cellspacing="0">
      <xsl:for-each select="$order/Charge">
         <tr class="charges">
            <td class="name"><xsl:value-of select="Description" />:</td>
            <td class="value"><xsl:value-of select="format-number(Amount, '#,##0.00')" /></td>
         </tr>
        </xsl:for-each>
       
      <tr id="orderTotal">
         <td class="name">Order Total:</td>
         <td class="value"><xsl:value-of select="format-number($order/Total, '#,##0.00')" /></td>
      </tr>
    </table>
</xsl:template>

<!--                                                            -->
<!-- Outputs a clickable tracking link for a shipment           -->
<!--                                                            -->
<xsl:template name="outputTrackingLink">
   
    <xsl:if test="TrackingNumber = ''">
        (No Tracking Available)
    </xsl:if>
   
    <xsl:if test="TrackingNumber != ''">
     
       <xsl:if test="starts-with(ServiceUsed, 'UPS')">
          <a href="http://wwwapps.ups.com/WebTracking/processInputRequest?HTMLVersion=5.0&amp;loc=en_US&amp;Requester=UPSHome&amp;tracknum={TrackingNumber}&amp;AgreeToTermsAndConditions=yes&amp;track.x=46&amp;track.y=9">
                <xsl:value-of select="TrackingNumber" />
            </a>
       </xsl:if>
       
       <xsl:if test="starts-with(ServiceUsed, 'USPS')">
          <a href="http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?origTrackNum={TrackingNumber}">
               <xsl:value-of select="TrackingNumber" />
            </a>
       </xsl:if>
       
       <xsl:if test="ShipmentType = 'FedEx'">
          <a href="http://www.fedex.com/Tracking?language=english&amp;cntry_code=us&amp;tracknumbers={TrackingNumber}">
               <xsl:value-of select="TrackingNumber" />
            </a>
       </xsl:if>
               
        <xsl:if test="ShipmentType = 'DHL'">
            <a href="http://track.dhl-usa.com/TrackByNbr.asp?ShipmentNumber={TrackingNumber}">
                <xsl:value-of select="TrackingNumber" />   
            </a>
        </xsl:if>
       
       <xsl:if test="not(starts-with(ServiceUsed, 'UPS')) and not(starts-with(ServiceUsed, 'USPS')) and not(ShipmentType = 'FedEx') and not(ShipmentType = 'DHL')">
          <xsl:value-of select="TrackingNumber" />
       </xsl:if>
    </xsl:if>
   
</xsl:template>

<!--                                                            -->
<!-- Outputs a table with all charges and totals                -->
<!--                                                            -->
<xsl:template name="outputStandardCss">
    <style>
   
        body, td, table, div { font: 8pt Arial;}
        table { border-collapse: collapse;}
        td {vertical-align: top;}
       
        /* Make all top-level tables exactly as wide as the content area */
        #addressinfo,
        #orderdetails,
        #totals,
        div.divider
        {
            width: <xsl:value-of select="//ContentWidth" />in;
        }
       
        #addressinfo
        {
           margin: 8 0 20 0;
        }
       
        #addressinfo td
        {
           padding:0;
           border:solid 1px dimgray;
        }
       
        #shipaddress td, #billaddress td
        {
           border:0;
           padding:4px;
           padding-left:10px;
        }
       
        #shipaddress td.header, #billaddress td.header
        {
           font-weight:bold;
           border-bottom:solid 1px dimgray;
           background-color:#F3F3F3;
           padding:1px;
           padding-left:5px;
        }
       
        #orderdetails
        {
           margin-top:5px;
            margin-bottom: 5px;
        }
           
        #orderdetails tr.header td
        {
           border: 1px solid dimgray;
           background-color:#F3F3F3;
           font-weight:bold;
           padding:3px;
        }
       
        #orderdetails tr.orderitem td
        {
           border-top: 1px solid lightgray;
           padding-top: 3px;
           padding-left: 8px;
           padding-right: 8px;
        }
       
        #orderdetails tr.itemoption td
        {
           color:#808080;
           padding-left: 2px;
           padding-right: 8px;
        }
       
        #orderdetails tr.itemoption td table.itemoptionname
        {
           margin-left:15px;
        }
       
        /* Can be used to create simple dividing line */
        div.divider
        {
            line-height: 0px;
           padding: 0;
            margin: 0px 0 5px 0;
           border-bottom: 1px solid rgb(180, 180, 180);
        }   
   
        #totals td
        {
            width: 100%;
           padding-right:8px;
            padding-left:16px;
           text-align:right;
        }
       
        #totals td.value
        {
            white-space: nowrap;
        }
       
        #totals #orderTotal td
        {
           font-weight:bold;
        }
       
    </style>
</xsl:template>
</xsl:stylesheet>


Last edited by Brett Berger on Tue Jan 03, 2012 6:50 am; edited 2 times in total
Back to top
View user's profile
motosmart



Joined: 22 Oct 2010
Posts: 19

PostPosted: Thu Dec 22, 2011 12:22 pm    Post subject: Cleaner, modified for 4 x 6 labels, & includes middle na Reply with quote

Brett, thanks for the great template. I wanted one I could easily print from my thermal printer when an address is too long to print nicely on a USPS label.

My version prints a landscape 4 x 6 label with bigger 20 pt. font, and includes the middle name which is left out on the original version. I also removed a bunch of unnecessary code so it's a cleaner template.

To make this work, just create a new blank template using the "Label" type and "HTML". Past in the entire code below on the "code" tab. Then, go to the "Settings" tab and click "Labels". Click "Edit", and enter a name for the new label size like "Plain 4 x 6". Choose the Sheet Size dimensions 6" and 4", and then Label Dimensions 4" high and 6" wide. Click OK, and you're all done! There may already be an Avery/Dymo/FedEx/UPS etc template that will work at this size, but I didn't know which one to select so I made my own.

Then click "Printing" and select your 4 x 6 thermal printer as the default for this label template. That's it! Here's the code:

Code:


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:sw="http://www.interapptive.com/shipworks" extension-element-prefixes="sw">
<xsl:output method="html" encoding="utf-8" indent="yes" />

<!-- -->
<!-- Start of processing -->
<!-- -->
<xsl:template match="/">

<html>
<head>
<style>
#labelcontent
{
white-space: nowrap;
padding: 16px;
border: 0;
width: 100%; height 100%;
font: 20pt Arial;
}

#labelcontent .contactName
{
font-weight: bold;
font-size: 20pt;
}
</style>
</head>
   
<!-- -->
<!-- Label Body -->
<!-- -->
<body>

<xsl:variable name="address">
<xsl:call-template name="selectLabelAddress" />
</xsl:variable>

<div id="labelcontent">
<xsl:call-template name="formatAddress">
<xsl:with-param name="address" select="msxsl:node-set($address)/*" />
</xsl:call-template>
</div>

</body>
</html>

</xsl:template>

   
<!-- -->
<!-- Format Address Settings -->
<!-- -->
<xsl:template name="formatAddress">
<xsl:param name="address" />
   
<xsl:if test="$address/FirstName != '' or $address/LastName != ''">
<span class="contactName">
<xsl:value-of select="$address/FirstName" />
<xsl:text> </xsl:text>
<xsl:value-of select="$address/MiddleName" />
<xsl:text> </xsl:text>
<xsl:value-of select="$address/LastName" />
</span>
<br />
</xsl:if>
<xsl:if test="$address/Company != ''">
<span class="companyName"><xsl:value-of select="$address/Company" /></span>
<br />
</xsl:if>
<xsl:value-of select="$address/Line1" />
<br />
<xsl:if test="$address/Line2 != ''">
<xsl:value-of select="$address/Line2" />
<br />
</xsl:if>
<xsl:value-of select="$address/City" />,
<xsl:value-of select="$address/StateName" /><xsl:text> </xsl:text>
<xsl:value-of select="$address/PostalCode" />
<br />
<xsl:if test="$address/CountryCode != 'US'">
<xsl:value-of select="$address/CountryName" />
<br />
</xsl:if>
   
</xsl:template>

   
<!-- -->
<!-- Selects the shipping label address to use based on the current context -->
<!-- -->
<xsl:template name="selectLabelAddress">

<xsl:if test="//Context = 'Customer'">
<xsl:copy-of select="//Customer[1]/Address[@type='ship']" />
</xsl:if>
<xsl:if test="//Context = 'Order'">
<xsl:copy-of select="//Order[1]/Address[@type='ship']" />
</xsl:if>
<xsl:if test="//Context = 'Shipment'">
<xsl:copy-of select="//Shipment[1]/Address[@type='ship']" />
</xsl:if>
   
</xsl:template>


</xsl:stylesheet>


_________________
Lincoln
www.MotoSmart.com
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic     Forum Index » Templates All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  

Powered by phpBB © 2001, 2002 phpBB Group