Paid feature

This is a paid feature. If you need more information, please contact tpm@deployteq.com for further details.

When sending an automated email filled by an external source like an RSS feed, JSON feed, or API, you might not always have complete control over the content that ends up being displayed in the email. For example, when working with recommendations, the external source might provide only one product while your content expects three. Even worse, the source could be empty.

With the cancel_mail function, you can cancel the entire email delivery or just the delivery for the current customer. So, if the external source doesn't provide any or only one product, you can stop the email delivery for the current customer.

In situations where the content is not as expected or when there's not enough content to fill the email, the cancel_mail function allows you to prevent sending incomplete or incorrect emails to customers.

cancel_mail

{{cancel_mail}}


Arguments

The following arguments can be used with the cancel_mail:

ArgumentDescription
for

The ability to indicate whether the delivery should be canceled for the entire selection or only the current customer for whom the email is being rendered. By default, this is for the current customer.

The following values are available:

  • currentcustomer
  • allcustomers

Examples

cancel_mail

{{* Stop the broadcast only for the current customer *}}
{{cancel_mail}}
{{cancel_mail for="currentcustomer"}}

{{* Stop the broadcast for all customers in the selection *}}
{{cancel_mail for="allcustomers"}}

Example with an product feed

Below is an example in combination with a product feed that is retrieved using the DataFeeds app, using the XML provided below:

XML productenfeed
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<item>
<id>1</id>
<title>Home loungeset Cardona</title>
<category>Tuinset</category>
<url>https://example.org/first-item</url>
<image>https://example.org/first-item.png</image>
<price>599.00</price>
<availability>In Stock</availability>
</item>
<item>
<id>2</id>
<title>Home loungeset Örebro</title>
<category>Tuinset</category>
<url>https://example.org/second-item</url>
<image>https://example.org/second-item.png</image>
<price>279.00</price>
<availability>In Stock</availability>
</item>
<item>
<id>3</id>
<title>Home loungeset Claire</title>
<category>Tuinset</category>
<url>https://example.org/third-item</url>
<image>https://example.org/third-item.png</image>
<price>479.00</price>
<availability>Sold out</availability>
</item>
</channel>
</rss>

In this process, it is checked whether there are products present in the feed and whether there is a sellable product among them. If these conditions are not met, the delivery is canceled for the entire selection. In this example, along with the cancel_mail function, the following Smarty methods are used: getRss, foreach, if, empty, lower, and counter:

cancel_mail bij getRSS

{{* Retrieve an XML feed *}}
{{getRss assign='productsXML' link='https://cdn.msdp1.com/public/tpm/xml/productfeed.xml'}}

{{* Loop through the products *}}
{{$available_products = 0 }}
{{foreach from=$productsXML.channel.0.item item=product}}
  {{if $product.availability|lower eq 'sold out'}}
   {{$product.title}} is sold out. 
  {{else}}
   {{counter assign="available_products"}}
   {{$product.title}} now available!
  {{/if}}
{{foreachelse}}
   {{* In case there are no products present, cancel the delivery for all customers in the selection.*}}
   {{cancel_mail for="allcustomers"}}
{{/foreach}}

{{* In the event that no sellable products are present, cancel the delivery for all customers in the selection. *}}
{{if empty($available_products)}}
   {{cancel_mail for="allcustomers"}}
{{/if}}