help with template

Comments

7 comments

  • Avatar
    Doug Rock

    Notice the last 2 lines.  They are the same SKU so they should be grouped together with a qty of 5.  However, (2) are promotional sales and 3 are not.  I want them grouped together, not separated.  Please assist.

    0
    Comment actions Permalink
  • Avatar
    Nathan H.

    Try changing your Item Group keys to SKU since that is what you want to group on.

    0
    Comment actions Permalink
  • Avatar
    Doug Rock

    wish I knew what that meant, this template was made by SW back in 2010

    0
    Comment actions Permalink
  • Avatar
    Robert K.

    Doug,

    Could you provide a bit of insight as to what is the difference between how the items show within ShipWorks? I see that they have the same SKU & Name from the screenshot. Is there an added attribute on the item? If that's the case I should be able to modify your template code to disregard attributes and only take into account SKUs.

    Please advise

    Thank you,

    Robert K 

    ShipWorks | Technical Support Representative - Tier 2

    One Memorial Drive, 20th Floor, Saint Louis, MO  63102 

    ShipWorks.com | 800.952.7784

    0
    Comment actions Permalink
  • Avatar
    Doug Rock

    Here is a picture of the template with the promotional info included. I assume the promotional discount is considered an "attribute".   I managed to omit it in the first screenshot by commenting it out in the template <!--   -->
    Yes I would like it to group SKU's so that the 056-18-F150-ti 3D carbon Black says a QTY of (5) and not a line of (2) and a line of (3)

    0
    Comment actions Permalink
  • Avatar
    Robert K.

    Doug,

    Give the following code a try and let me know if it groups the items together as you are wanting:

    <!DOCTYPE xsl:stylesheet [

    <!-- This can be used to control if items are grouped based on options -->
    <!ENTITY optionSpecific "true()">

    <!-- This is the lookup key value for the grouping table -->
    <!ENTITY itemKey "sw:GetOrderItemKeyValue(., &optionSpecific;)">
    ]>

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sw="http://www.interapptive.com/shipworks" extension-element-prefixes="sw">

     

    <!-- Import core functions from Common -->
    <xsl:import href="ShipWorks2\System\Common" />

    <xsl:output method="html" encoding="utf-8" indent="yes" />

    <!-- This can be changed to false to turn off thumbnails -->
    <xsl:variable name="showThumbnails" select="false()" />


    <!-- Setup the key table for grouping by item code -->
    <xsl:key name="items" match="Item" use="sw:GetOrderItemKeyValue(., false())" />

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

    <html>

    <head>
    <title>
    Pick List
    </title>

    <!-- Output all the CSS required for this template -->
    <xsl:call-template name="outputStandardCss" />

    <style>
    h1
    {
    font-size: 12pt;
    }

    <!-- BEGIN highlight color every other row part 1 of 2 -->
    h3
    {
    font-size: 9pt;
    }

    tr.altrow
    {
    background-color: #C0C0C0;
    }
    <!-- END highlight color every other row part 1 of 2 -->


    </style>

    </head>

    <body>

    <!-- Determine the order with the larget order number -->
    <xsl:variable name="maxOrder">
    <xsl:for-each select="//Order">
    <xsl:sort order="descending" select="Number" data-type="number" />
    <xsl:if test="position() = 1"><xsl:copy-of select="Number" /></xsl:if>
    </xsl:for-each>
    </xsl:variable>

    <!-- Determine the order with the smallest order number -->
    <xsl:variable name="minOrder">
    <xsl:for-each select="//Order">
    <xsl:sort order="ascending" select="Number" data-type="number" />
    <xsl:if test="position() = 1"><xsl:copy-of select="Number" /></xsl:if>
    </xsl:for-each>
    </xsl:variable>

    <!-- Title (System Skins & Date) -->
    <h1>System Skins -- <xsl:value-of select="sw:ToShortDate(//Generated)" /></h1>

    <table id="orderdetails" cellspacing="0" cellpadding="0">


    <tr>
    <td>
    Total Items: <xsl:value-of select="sum(//Order/Item/Quantity)" />
    </td>
    <td>
    System Skins:

    <xsl:if test="//Order/Item[contains(translate(Name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'console')]">
    <xsl:value-of select="sum(//Order/Item[contains(translate(Name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'console')]/Quantity)" />
    </xsl:if>

    Necro Wraps:

    <xsl:if test="//Order/Item[contains(translate(Name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'necro wraps')]">
    <xsl:value-of select="sum(//Order/Item[contains(translate(Name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'necro wraps')]/Quantity)" />
    </xsl:if>


    Bumper Inserts:

    <xsl:if test="//Order/Item[contains(translate(Name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'insert')]">
    <xsl:value-of select="sum(//Order/Item[contains(translate(Name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'insert')]/Quantity)" />
    </xsl:if>

    Total Sales: $<xsl:value-of select="format-number(sum(//Order/Item/UnitPrice),'#,##0.00')" />

    </td>
    <td align="right">

     


    </td>

    <td align="right"><xsl:value-of select="sw:ToShortTime(//Generated)" /></td>
    </tr>

    <tr class="header">
    <td>SKU</td>
    <td>Name</td>
    <td align="right">Need</td>
    <td align="center">Cut</td>
    </tr>

    <!-- Group by item code -->
    <xsl:for-each select="//Order/Item[generate-id(.)=generate-id(key('items', sw:GetOrderItemKeyValue(., false())))]">

    <xsl:sort select="SKU" />

    <!-- Get all items for this group -->
    <xsl:variable name="items" select="key('items', sw:GetOrderItemKeyValue(., false()))" />

    <!-- BEGIN highlight color every other row part 2 of 2 -->
    <xsl:variable name="classname">
    <xsl:if test="position() mod 2 = 1">
    <xsl:text></xsl:text>
    </xsl:if>
    <xsl:if test="position() mod 2 = 0">
    <xsl:text>altrow</xsl:text>
    </xsl:if>
    </xsl:variable>
    <xsl:if test="SKU != ''">
    <tr class="orderitem {$classname}">
    <!-- END highlight color every other row part 2 of 2 -->

    <!-- Replaced for highlight color every other row <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:value-of select="substring(SKU, 1, 40)" /></td>
    <td><xsl:value-of select="substring(Name, 1, 70)" /></td>
    <td align="right"><xsl:value-of select="sum($items/Quantity)" /></td>
    <td align="center" style="color:#000000;">____</td>
    </tr>


    <!--
    <xsl:if test="true()">

    <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>
    <td></td>
    </tr>

    </xsl:for-each>

    </xsl:if> -->
    </xsl:if>
    </xsl:for-each>

    </table>

    </body>
    </html>

    </xsl:template>

    </xsl:stylesheet>

    0
    Comment actions Permalink
  • Avatar
    Doug Rock

    That worked, thanks Robert !

    0
    Comment actions Permalink

Please sign in to leave a comment.