Conditional Tags

One or more parts of an email template can be removed by wrapping the section in conditional email tags.

A conditional email tag is different from a normal email tag because it starts and ends with curly braces (”{“ and “}”) followed by a question mark, instead of the usual square braces (“[“ and “]“). The email tag [Detail.ShippingAmount] is normally replaced with a value such as “9.95” when the email is sent out. If there is no shipping, then the tag would be replaced with “0.00”, but would still be shown in the email.

Using conditional tags it is possible to remove the surrounding text if it is not applicable.

Example:
{?Detail.ShippingAmount}Shipping Amount: [Detail.ShippingAmount] {?end}

In this case, if the shipping is zero then none of the text “Shipping Amount: 0.00“ would be displayed in this email. If the shipping amount is greater than zero then all of the text “Shipping Amount: 9.95” would be displayed.

To go a step further, the {?else} tag can be incorporated.

Example:
{?Receiver.IsVerified}
<p>Hello, [Receiver.FirstName]</p>
{?else}
<p>Howdy, Tim</p>
{?end}

Any site property can become a dynamic aspect of the email template.

Example:
{?#UserMessagingEnabled} … text to show if setting is true … {?else} …optional text to show if false … {?end}
You can also just use the simplified form:
{?#UserMessagingEnabled} … text to show if setting is true … {?end}

You can replace “UserMessagingEnabled” with the name of any non-date site property in any email template.

 

Comparator Conditional Tags

Note: Comparator Conditional Tags have been implemented in AuctionWorx 3.1.6697 or later. (builds after May 3rd 2018)

Email templates can have conditional tags that check against a specific value. The general format is either…

{?ComparisonOperatorTestValue|TagName}text A{?else}text B{?end}

… or …

{?ComparisonOperatorTestValue|TagName}text A{?end}

…where:

  • ComparisonOperator is one of these 6 values:
    • = (equal to)
    • <> (not equal to)
    • < (less than; only works with numeric values)
    • > (greater than; only works with numeric values)
    • <= (less than or equal to; only works with numeric values)
    • >= (greater than or equal to; only works with numeric values)
  • TestValue is either a numeric value or a comma-delimited text value
    • Text comparison is case insensitive, so “Cat” would be considered equal to “cAt”)
    • = (equal to) is the only operator that is supported for non-numeric values
    • For text values only, if the value contains commas then it will be treated as a match if it matches any of the values in the list
  • TagName is any valid email tag, e.g. Detail.ID, Detail.Listing.Title, etc.

 

Below is a working example: (assuming the email template detail type is “Listing”)

<p />
<h3>ACTUAL TYPE: [Detail.Type.Name]</h3>
{?=FiXeDpRiCe|Detail.Type.Name}
<h4>This is a fixed price listing</h4>
{?else}
<h4>This is NOT a fixed price listing</h4>
{?end}
{?=auction,classified|Detail.Type.Name}
<h4>This is either an auction listing or a classified ad</h4>
{?end}
<h3>ACTUAL QUANTITY: [Detail.CurrentQuantity]</h3>
{?<96|Detail.CurrentQuantity}<h4>(with quantity less than 96)</h4>{?else}<h4>(with quantity NOT less than 96)</h4>{?end}
{?<=96|Detail.CurrentQuantity}<h4>(with quantity less than or equal to 96)</h4>{?else}<h4>(with quantity NOT less than or equal to 96)</h4>{?end}
{?=96|Detail.CurrentQuantity}<h4>(with quantity equal to 96)</h4>{?else}<h4>(with quantity NOT equal to 96)</h4>{?end}
{?>=96|Detail.CurrentQuantity}<h4>(with quantity greater than or equal to 96)</h4>{?else}<h4>(with quantity NOT greater than or equal to 96)</h4>{?end}
{?>96|Detail.CurrentQuantity}<h4>(with quantity greater than 96)</h4>{?else}<h4>(with quantity NOT greater than 96)</h4>{?end}
{?<>AnythingButThisValue|Detail.MyPropertyName}<h4>As long as the "MyPropertyName" is not "AnythingButThisValue" then this message appears.</h4>{?end}
<p />

 

Nested Comparator Conditional Tags

AuctionWorx also supports nested conditional tags. In some circumstances you may need to an IF statement within another IF statement. Up to 4 levels of nested comparator conditional tags are supported.

Using the {?=<Value>|<DetailPropTag>}...{?else}...{?end} pattern, you can now put a "1", "2" or "3" between the '{' and the '?' characters, so that the 'end' and 'else' tags get matched up with each other correctly.

Below is a working example of how the Send Consignor Statement email template uses nested comparator conditional tags to support hiding 0-value listing fees, but only when the Hide Listing Fees On Statement When Zero site property is set to False. When the Hide Listing Fees On Statement When Zero site property is set to True and the listing fee is zero, this code will display nothing.

 

{1?=False|#HideListingFeesOnStatementWhenZero}
  Listing Fee: [Detail.LineItems.ListingFee(currency(C|Detail.LineItems.CurrencyCode))] [Detail.LineItems.CurrencyCode]<br/>
{1?else}
  {2?>0|Detail.LineItems.ListingFee}
    Listing Fee: [Detail.LineItems.ListingFee(currency(C|Detail.LineItems.CurrencyCode))] [Detail.LineItems.CurrencyCode]<br/>
  {2?end}
{1?end}