Follow Up Email
v2.7.4

Variables & Methods

Our extension allows you to use variables and PHP callouts in your emails, which can greatly enhance and personalize them.

Note

Both variables and callouts can be used simultaneously, and are fully interchangeable so you can select your preferred syntax, and use it for all of your customizations.

Liquid is the preferred syntax for use with Email Templates. It allows you to avoid errors with the absence of attributes or values. Moreover, we provide a convenient helper dialog for inserting liquid variables into the editor.

Callouts are deprecated syntax, and used mainly for backward compatibility with older Follow-Up Email versions.

Liquid Variables

Liquid variables are a new way to enhance email templates. This syntax was introduced in version 1.1.15 and is the preferred syntax for use in Email Templates.

All variables should be enclosed in curly brackets. Each variable can also have a filter, added after pipe sign, and have one or more parameters.

Example

  1. {{ attribute | filter }}
  2. {{ entity.attribute | filter | filter: param1 }}
  3. {{ entity.entity.attribute | filter: param1,param2 }}

These variables can be added interactively from edit pages of Theme or Template.

You just need to press the button Insert Variable near the content element, and select the variable you want to use - as shown below: Insert Variable

Modifying Variables with Filters

Filters are methods that allow you to alter or enhance the output of a variable. They also should be enclosed to the variable block {{ }}, but separated from the variable with a pipe (|) character. The parameters of filters are added using the colon (:) character.

Example

  • {{ item.product.name | truncate: '150' }} - truncates the name of the product to 150 characters/
  • {{ item.product.weight | round: '2' }} kg - rounds the weight of the product to 2 decimal digits

Here is the list of available filters, grouped into categories, with examples:

  • String/HTML Filters

    • downcase - converts a string into lowercase.

      {{ item.product.name | downcase }}

      • Original: Dash Digital Watch
      • Output: dash digital watch
    • upcase - converts a string into uppercase.

      {{ item.product.name | upcase }}

      • Original: Dash Digital Watch
      • Output: DASH DIGITAL WATCH
    • replace - replaces all occurrences of a string with a substring.

      {{ item.product.name | replace: 'Digital', 'Analog' }}

      • Original: Dash Digital Watch
      • Output: Dash Analog watch
    • append - appends characters to a string.

      {{ item.product.name | append: ' - best choice' }}

      • Original: Dash Digital Watch
      • Output: Dash Digital Watch - best choice
    • prepend - prepends characters to a string.

      {{ item.product.name | prepend: 'Best choice - ' }}

      • Original: Dash Digital Watch
      • Output: Best choice - Dash Digital Watch
    • capitalize - capitalizes words in the input sentence.

      {{ item.product.color | capitalize }}

      • Original: dark red
      • Output: Dark red
    • escape - escapes HTML tags in a string.

      {{ item.product.description | escape }

    • newline_to_br - inserts a <br> linebreak HTML tag in front of each line break in a string.

      {{ item.product.short_description | newline_to_br }

    • remove - removes all occurrences of a substring from a string.

      {{ item.product.name | remove: 'Digital' }}

      • Original: Dash Digital Watch
      • Output: Dash Watch
    • strip_html - strips all HTML tags from a string.

      {{ item.product.description | strip_html }

    • truncate - truncates a string down to 'x' characters.

      {{ item.product.name | truncate: '15' }}

      • Original: Dash Digital Watch
      • Output: ash Digital Wa
    • if_empty - return argument, if the value is an empty string

      Dear {{ customer_name | if_empty: 'Client' }}!

      • Original: empty string
      • Output: Dear Client!
    • date - converts a string to a specified date-time format.

      {{ item.product.created_at | date: '%d.%m.%Y %H:%M' }}

      • Original: 2016-02-18 10:11:12
      • Output: 18.02.2016 10:11

      Full list of formatters can be found here

    • format_date - converts a string to a specified date-time format.

      {{ item.product.created_at | format_date: 3 }}

      • Original: 2016-02-18 10:11:12
      • Output: 18/02/16

      Possible formatters: 0, 1 , 2 , 3

  • Numeric Filters

    • ceil - rounds the output up to the nearest integer.

      {{ item.product.weight | ceil }}

      • Original: 1.423
      • Output: 2
    • floor - rounds the output down to the nearest integer.

      {{ item.product.weight | floor }}

      • Original: 1.423
      • Output: 1
    • round - rounds the output to the nearest integer or specified decimal digits.

      {{ item.product.weight | round: '2' }}

      • Original: 1.423
      • Output: 1.42

      {{ item.product.weight | round }}

      • Original: 1.423
      • Output: 1
    • number_format - formats number to specified format (php function).

      {{ item.product.price | number_format: '2', '.', ',' }}

  • Price/Currency Filters

    • format_price - formats price to default format.

      {{ item.product.price | format_price }}

      • Original: 100.42
      • Output: $100.42
    • convert - converts a price from base currency to specified currency.

      {{ item.product.price | convert: 'EUR' }}

      • Original: 100
      • Output: 92.28
  • Array Filters

    • first - return first element in array.

    • last - return last element in array.

    • join - join array to string using glue.

    • size - return the size of an array or a string.
  • URL Filters

    • resume - resume customer's session and redirect it to base URL

      {{ item.product.product_url | resume }}

  • Image Filters

    • resize - resize image

      {{ item.product.image | resize: 'small_image', 100, 100 }}

      • Original: http://example.com/pub/media/catalog/product/m/h/mh03-black_main.jpg
      • Output: http://example.com/pub/media/cache/100x100/catalog/product/m/h/mh03-black_main.jpg

PHP Callouts

PHP Callouts is a very powerful tool to enhance your templates. It allows you to include PHP code directly to the HTML Code.

Here is the list of possible callouts with respective examples:

  • Global Methods

    • getUnsubscribeUrl - a direct link to unsubscribe from current trigger.

      The customer will be unsubscribed from all already scheduled emails (Follow Up Email -> Mail Log (Queue)) for the current trigger.

      This link does not unsubscribe customers from future emails (triggered by other events) or native Magento subscription.

      Usage: <a href="<?php echo $this->getUnsubscribeUrl() ?>">Unsubscribe</a>

    • getUnsubscribeAllUrl - a direct link to unsubscribe from all triggers

      The customer will be unsubscribed from all already scheduled emails (Follow Up Email -> Mail Log (Queue)) for all triggers.

      This link does not unsubscribe customers from native Magento subscription.

      Usage: <a href="<?php echo $this->getUnsubscribeAllUrl() ?>">Unsubscribe</a>

    • getViewInBrowserUrl - a direct link to open email in browser

      Usage: <a href="<?php echo $this->getViewInBrowserUrl() ?>">View it in your browser.</a>

    • getResumeUrl - a direct link to resume (restore, log in) customer session

      Usage: <a href="<?php echo $this->getResumeUrl() ?>">Open</a>

      i.e., the customer will be automatically authorized in the store.

      Additionally, you can pass a parameter to the method to redirect the customer to a specific URL after authorization.

      Example

          <?php foreach($this->getOrder()->getAllVisibleItems() as $item): ?>
            <tr>
              <td>
                <a href="<?php echo $this->getResumeUrl($item->getProduct()->getProductUrl()) ?>">Review <?php echo $item->getName() ?></a>
              </td>
            </tr>
          <?php endforeach ?>

      i.e., the customer will be redirected to the product page to leave a review after automatic authorization.

    • getStoreUrl - a direct link to the store home page

      Usage: <?php echo $this->getStoreUrl() ?>

    • getStoreName - a curent store name

      Usage: <?php echo $this->getStoreName() ?>

    • getStorePhone - a curent store phone

      Usage: <?php echo $this->getStorePhone() ?>

    • getStoreAddress - a curent store address

      Usage: <?php echo $this->getStoreAddress() ?>

    • getStoreEmail - a curent store general transactional email

      Usage: <?php echo $this->getStoreEmail() ?>

  • Customer Methods

    • getCustomerName - returns customer's full name

      Usage: Dear <?php echo $this->getCustomerName() ?>

      You can pass a parameter to the method getCustomerName() which will be used instead of the customer name, if the customer's name is empty: Dear <?php echo $this->getCustomerName(null, 'Customer') ?>, results in Dear Customer, if customer's name is empty (since version 1.0.34).

    • getFirstname - returns customer's firstname (since version 1.0.36)

      Usage: Dear <?php echo $this->getFirstname() ?>

    • getLastname - returns customer's lastname (since version 1.0.36)

      Usage: Dear <?php echo $this->getLastname() ?>

    • getCustomer - retrurns customer's object (only for registered customers)

      Usage: Hi <?php echo $this->getCustomer()->getFirstname() ?>

      <?php echo $this->getCustomer()->getEmail() ?>

  • Shopping Cart Methods

    • getRestoreCartUrl - a direct link to customer shopping cart

      Usage: <a href="<?php echo $this->getRestoreCartUrl() ?>">Finish Checkout!</a>

    • getReorderCartUrl - redirects the customer to the quote with the products purchased from the previous order

      Usage: <a href="<?php echo $this->getReorderCartUrl() ?>">Reorder</a>

    • getQuote()->getAllVisibleItems() - return collection of products in cart for feature output

      Usage:

          <?php foreach ($this->getQuote()->getAllVisibleItems() as $item): ?>
              <?php echo $item->getName() ?>
          <?php endforeach ?>

      How to display only the first product:

      Example

          <?php $i = 0 ?>
          <?php foreach ($this->getQuote()->getAllVisibleItems() as $item): ?>
              <?php if ($i++ >= 1): ?>
                  <?php break ?>
              <?php endif ?>
              ...
              other methods
              ...
          <?php endforeach ?>

  • Order Methods

    • getOrder()->getStatus() - the status of order

      Usage: order status is <?php echo $this->getOrder()->getStatus() ?>

    • getOrder()->getIncrementId() - the order number

      Usage: Order #<?php echo $this->getOrder()->getIncrementId() ?>

    • getOrder()->getStoreGroupName() - the store name of order

      Usage: You placed order in <?php echo $this->getOrder()->getStoreGroupName() ?>

    • getOrder()->getAllVisibleItems() - return list of products in order for feature output

      Usage:

          <?php foreach ($this->getOrder()->getAllVisibleItems() as $item): ?>
              <?php echo $item->getName() ?>
          <?php endforeach ?>

      How to display only the first product:

      Example

          <?php $i = 0 ?>
          <?php foreach ($this->getOrder()->getAllVisibleItems() as $item): ?>
              <?php if ($i++ >= 1): ?>
                  <?php break ?>
              <?php endif ?>
              ...
              other methods
              ...
          <?php endforeach ?>

    • Additional Methods

      Usage:

          <?php echo $this->getOrder()->getBaseTaxAmount() ?>
          <?php echo $this->getOrder()->getBaseGrandTotal() ?>
          <?php echo $this->getOrder()->getBaseShippingAmount() ?>
          <?php echo $this->getOrder()->getShippingDescription() ?> - returns shipping method name

  • Coupons

    • getCoupon()->getCode() - get the expiration date of an autogenerated coupon code

      Usage: Expiration date: <?php echo $this->formatDate($this->getCoupon()->getExpirationDate()) ?>

      Different date formats:

          <?php echo $this->formatDate($this->getCoupon()->getExpirationDate()) ?>
          <?php echo $this->formatDate($this->getCoupon()->getExpirationDate(), \IntlDateFormatter::MEDIUM) ?>
          <?php echo $this->formatDate($this->getCoupon()->getExpirationDate(), \IntlDateFormatter::LONG) ?>

      Example

          <?php if ($this->getCoupon()): ?>
              Let us offer you a discount to complete your purchase.<br>
              Your coupon code: <?php echo $this->getCoupon()->getCode() ?> valid till <?php echo $this->formatDate($this->getCoupon()->getExpirationDate(), \IntlDateFormatter::MEDIUM) ?>
          <?php endif ?>

      i.e., we only display this text block if a coupon is available.

    • getCoupon()->getExpirationDate() - the autogenerated coupon code

      Usage: Your coupon code: <?php echo $this->getCoupon()->getCode() ?>

      Example

          <?php if ($this->getCoupon()): ?>
              Let us offer you a discount to complete your purchase.<br>
              Your coupon code: <?php echo $this->getCoupon()->getCode() ?>
          <?php endif ?>

      i.e., we only display this text block if a coupon is available.

  • Cross-sell products

    • getCrossSellHtml - html block of cross sell products

      Usage: <?php echo getCrossSellHtml() ?>

      Example

          <?php if ($this->getCrossSellHtml()): ?>
              <h1>See also:</h1>
              <?php echo $this->getCrossSellHtml() ?>
          <?php endif ?>

      i.e., we only display this text block if products are available.

  • Products Methods

    • getProductUrl - a direct link to the product

      Usage: <?php echo $item->getProduct()->getProductUrl() ?>

    • getPrice - a price of the product

      Usage: <?php echo $item->getProduct()->getPrice() ?>

      <?php echo $this->formatPrice($item->getProduct()->getPrice()) ?>

    • getPriceInclTax - a price of the product with tax (saved in order/shopping cart)

      Usage: <?php echo $item->getPriceInclTax() ?>

      <?= $this->formatPrice($item->getPriceInclTax()) ?>

    • getName - a name of the product

      Usage: <a href="<?php echo $item->getProduct()->getProductUrl() ?>"><?php echo $item->getName() ?></a>

    • Image Directive

      Usage: <img src="<?php echo $this->getImageUrl($item->getProduct(), 'image', 100) ?>"/>

      <img src="<?php echo $this->getImageUrl($item->getProduct(), 'small_image', 150) ?>"/>

      <img src="<?php echo $this->getImageUrl($item->getProduct(), 'thumbnail) ?>"/>

  • Wishlist Methods

    • getWishlist()->getItemCollection() - return collection of products in wishlist for feature output

      Usage:

          <?php foreach ($this->getWishlist()->getItemCollection() as $item): ?>
              <img src="<?=$this->getImageUrl($item->getProduct(), 'image', 300) ?>"/>
              <a href="<?= $item->getProduct()->getProductUrl() ?>"><?php echo $item->getProduct()->getName() ?></a>
          <?php endforeach ?>

      Alternative way of retrieving wishlist products:

          <?php foreach ($this->getWishlistItemCollection() as $item): ?>
              <img src="<?=$this->getImageUrl($item->getProduct(), 'image', 300) ?>"/>
              <a href="<?php echo $item->getProduct()->getProductUrl() ?>"><?php echo $item->getProduct()->getName() ?></a>
          <?php endforeach ?>
    • getWishlistProduct() - return last added product to wishlist for feature output

      Usage:

      <a href="<?php echo $this->getWishlistProduct()->getProductUrl() ?>"><?php echo $this->getWishlistProduct()->getName() ?></a>

      Price: <?php echo $this->getWishlistProduct()->getPrice() ?>

  • Helper Methods

    Tip

    The code below can be used to see available methods/properties for each of the mentioned above objects (product, quote, quote item, order, order item, order shipping address, order payment, customer, wishlist):
    • Print all properties for order object:

      Usage:

          <?php
          echo '<pre>';
          print_r($this->getOrder()->debug());
          echo ' </pre>';
          die();
          ?>
    • Print all properties for order item object:

      Usage:

          <?php foreach ($this->getOrder()->getAllVisibleItems() as $item): ?>
              <?php
              echo '<pre>';
              print_r($item->debug());
              echo ' </pre>';
              die();
              ?>
          <?php endforeach ?>
    • Print all properties for product object:

      Usage:

          <?php foreach ($this->getOrder()->getAllVisibleItems() as $item): ?>
              <?php
              echo '<pre>';
              print_r($item->getProduct()->debug());
              echo ' </pre>';
              die();
              ?>
          <?php endforeach ?>
    • Print all properties for customer object:

      Usage:

          <?php
          echo '<pre>';
          print_r($this->getCustomer()->debug());
          echo ' </pre>';
          die();
          ?>
    • Print all properties for wishlist object:

      Usage:

          <?php
          echo '<pre>';
          print_r($this->getWishlist()->debug());
          echo ' </pre>';
          die();
          ?>

      Note

      Object data returned as an array consisting of all the available data for the specified object. The object properties are displayed in the following way:

      [property_code] => property value
      [another_property_code] => property value
      [one_more_property_code] => property value

      Each property can be accessed separately as follows:

      <?php echo $this->getOrder()->getPropertyCode() ?>
      <?php echo $this->getOrder()->getAnotherPropertyCode() ?>
      <?php echo $this->getOrder()->getShippingAddress()->getAnotherPropertyCode() ?>
      <?php echo $this->getOrder()->getPayment()->getPropertyCode() ?>
      <?php echo $this->getCustomer()->getPropertyCode() ?>
      <?php echo $this->getWishlist()->getOneMorePropertyCode() ?>
      <?php echo $item->getProduct()->getPropertyCode() ?>