help with template
I created a social media promotion on Amazon and now that the orders are coming in from that promotion, my pick list is showing items that were purchased with that promotion separately from the same items that were not purchased with the promotion. Can someone help me remove the "promotional" information out of my pick list and add the quantity of the promotional items and non promotional items together?
<!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(., true())" />
<!-- -->
<!-- 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(., true())))]">
<xsl:sort select="SKU" />
<!-- Get all items for this group -->
<xsl:variable name="items" select="key('items', sw:GetOrderItemKeyValue(., true()))" />
<!-- 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>
-
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
-
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) -
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>
Please sign in to leave a comment.
Comments
7 comments