How to use placeholders supporting template views

Most placeholders rely on showing just text content, which you can compose into a message, but there are a few special placeholders that can output more structured content with pictures to the email message. In such case it would be good to be able to decide, what kind of output you would like to show your customers - should it be just a plain list of ordered products of the grid with images of upselling recommendations.

Placeholders with template argument

Those placeholders accept a template argument to specify how would you like to show the items in your message.

  • {{ order.products_ordered }}
  • {{ order.related_products }}
  • {{ order.cross_sells }}
  • {{ order.products_ordered_review_links }}
  • {{ order.products_ordered_links }}
  • {{ subscription.items }}

All placeholders listed above mutually have templates for the comma separated list and bullet list. Additionally, some placeholders can also show items in a grid with a template in 2 or 3 columns. Placeholders that support this type of view are {{ order.products_ordered }} , {{ order.related_product }} , {{ order.cross_sells }} .

Generally, the list of available templates for placeholder is:

  • Comma separated list
  • Bullet list
  • Grid - 2 columns
  • Grid - 3 columns

Constraints

Using the grid template is restricted only to Send Mail action in HTML version with WooCommerce template for email. Send Mail (Plain) or custom email template action doesn't include any stylesheet needed to properly set your items in a grid. If you'd like to use a grid template in your custom email template, you need to provide your own stylesheet definition. You can find required CSS classes in files inside shopmagic-for-woocommerce/templates/placeholder/products_ordered folder.

Extending templates

With a bit of coding, you can extend or override placeholder templates.

In your theme add the folder shopmagic/placeholder/products_ordered and put there any template you would like to add or override.

If you are overriding our templates, the name of the file must match the template name, i.e. for a Comma separated list, create file comma_separated_list.php .

If you wish to add some templates to placeholders, besides adding a template file in folder, you need to register it to use, by hooking a filter shopmagic/core/placeholder/products_ordered/templates . In the filter, you need to register the file name and the label for display in an associative array, as in the example below.

You can add this snippet to your functions.php in theme.

add_filter('shopmagic/core/placeholder/products_ordered/templates', static function (array $templates): array {
  $templates['my_placeholder_template'] = esc_html__('My placeholder template');
  return $templates;
});
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us