Documentation

Adding shortcodes to emails

ShopMagic does not process WordPress shortcodes by default. To enable them in email content, add this filter to your theme’s functions.php file:

add_filter( 'shopmagic/core/action/sendmail/raw_message', 'do_shortcode' );

The filter is available from ShopMagic 2.2.

It applies to the Message field in these actions:

  • Send Email
  • Send Email - Raw HTML
  • Send Email - Plain Text

It does not process shortcodes in Subject or Heading.

ShopMagic replaces placeholders before running do_shortcode(). Placeholders returned by a shortcode are not processed again.

Output requirements#

Shortcode output must be suitable for the selected email format:

  • Send Email and Send Email - Raw HTML: use HTML compatible with email clients. Shortcode markup intended for website pages may break the email layout.
  • Send Email - Plain Text: use shortcodes that return plain text. HTML returned by a shortcode is not removed after the filter runs.

Disabling shortcode processing#

Remove the add_filter() line above to disable shortcode processing in email content.

Not the solution you are looking for?

Please check other articles or open a support ticket.