Help with template variables

Comments

5 comments

  • Official comment
    Avatar
    Robert K

    Hello Rob,

    Thank you for your inquiry about our templates. I will lead off by answering your last question.

    The best way to see which fields can go into a template from an order is to take a look at the XML Source for said order. You may see the order XML by selecting an order and going to Output > Save & Open > System > Utility > XML Source. The resulting file will list the possible values to be displayed in a template from the selected order.

    Here are paths for the fields you asked for (starting at the Order level of the XML).

    Custom field 1: <xsl:value-of select="//Order/CustomField1"/>

    Processed Date (formatted using the ShipWorks short date function, note that this will fail if attempted to be used with non-processed shipments): <xsl:value-of select="sw:ToShortDate(//Order/Shipment/ProcessedDate)"/>

    Service Used: <xsl:value-of select="//Order/Shipment/ServiceUsed"/>

    If you have any further template questions please let me know and I will be happy to provide clarification and, if necessary, open a support ticket on your behalf.

    Thank you,

    Robert K

    Comment actions Permalink
  • Avatar
    Rob Johnson

    Thank you!  Is there a way to get Carrier and Service Used separately? 

    UPS

    Ground

     

    instead of UPS GROUND

    0
    Comment actions Permalink
  • Avatar
    Jacob Hutter

    Hey Rob,

    In Order to separate the Carrier Name from the service, we'll have to remove it from the tag with XSLT Code. Although it looks like a lot, the code is clean and simple!

    Feel free to Copy/Paste the code below to look for USPS, FedEx, and UPS' Service w/o the Carrier name:

    <xsl:if test="contains(//ServiceUsed, 'UPS')" >
       <xsl:value-of select="substring-after(//ServiceUsed, 'UPS ')" />
    </xsl:if>
    <xsl:if test="contains(//ServiceUsed, 'FedEx')" >
       <xsl:value-of select="substring-after(//ServiceUsed, 'FedEx ')" />
    </xsl:if>
    <xsl:if test="contains(//ServiceUsed, 'USPS')" >
       <xsl:value-of select="substring-after(//ServiceUsed, 'USPS ')" />
    </xsl:if>

    Don't hesitate to let us know if we can further assist!

    Bet Regards,

    Jake H

    -Let's Do It!

    0
    Comment actions Permalink
  • Avatar
    Rob Johnson

    Thank you! 

     

    I'm trying to make a report that creates a csv file. Everything is working fine except for one thing that I can't seem to pull off. 

    I am making csv that is for invoice uploading. So it needs to breakdown evey order on multiple lines if need depending on how many skus were ordered. Near the end I need to display the Order Total on each line item. But "Total" in this case seems to equal Total of unit price for the line items on that line and not Order Total. I've tried Total, //Order/Total and a million other things to try to get Unit Price and Order Total to co-exist on the same line item. 

     

     

    <xsl:text>"invoice_id","po_number","invoice_date","ship_date","line_item_sku","line_item_quantity","line_item_unit_of_measure","line_item_unit_price","line_item_basis_of_unit_price","invoice_total_amount","invoice_terms_type"&nl;</xsl:text>

    <xsl:for-each select="Customer/Order/Item">


    <!-- order id / date -->

    <xsl:text>"</xsl:text><xsl:call-template name="OrderNumber"><xsl:with-param name="order" select=".." /></xsl:call-template><xsl:text>",</xsl:text>
    <xsl:text>"</xsl:text><xsl:call-template name="OrderNumber"><xsl:with-param name="order" select=".." /></xsl:call-template><xsl:text>",</xsl:text>
    <xsl:text>"</xsl:text><xsl:value-of select="sw:FormatDateTime(//Generated, 'yyyy-MM-dd')" /><xsl:text>",</xsl:text>
    <xsl:text>"</xsl:text><xsl:value-of select="sw:FormatDateTime(//Order/Shipment/ProcessedDate, 'yyyy-MM-dd')" /><xsl:text>",</xsl:text>

    <!-- line item info -->

    <xsl:text>"</xsl:text><xsl:value-of select="SKU" /><xsl:text>",</xsl:text>
    <xsl:text>"</xsl:text><xsl:value-of select="Quantity" /><xsl:text>",</xsl:text>
    <xsl:text>"EA",</xsl:text>
    <xsl:text>"</xsl:text><xsl:value-of select="format-number(UnitPrice, '#,##0.00')" /><xsl:text>",</xsl:text>
    <xsl:text>"QT",</xsl:text>

    <!-- order total -->
    <xsl:text>"</xsl:text><xsl:value-of select="//Order/Total" /><xsl:text>",</xsl:text>

    <xsl:text>"01"</xsl:text>
    <xsl:text>&nl;</xsl:text>
    </xsl:for-each>

    0
    Comment actions Permalink
  • Avatar
    Rob Johnson

    Sorry just got it..   ../Total 

    0
    Comment actions Permalink

Please sign in to leave a comment.