Additional Custom Emails & Recipients for WooCommerce fills your email content from two systems: placeholders wrapped in curly braces, and shortcodes wrapped in square brackets. This page lists both, what each returns, and the common attributes that most shortcodes accept. All of these work in the Subject, Email heading, and Email content fields of any custom email, at WooCommerce > Settings > Emails.
Placeholders vs shortcodes #
They are different systems that are easy to confuse:
- Placeholders use curly braces, for example
{order_number}. There are only four of them. They are simple text swaps, applied first. - Shortcodes use square brackets, for example
[order_number]. There are many, and they accept attributes. They are processed after placeholders.
Both {order_number} and [order_number] print the order number, but they are not the same feature. When you need attributes such as formatting or a prefix, use the shortcode form.
The four placeholders #
| Placeholder | Returns | Available in |
|---|---|---|
{site_title} |
Your site’s title | Every email |
{site_address} |
Your site’s domain | Every email |
{order_number} |
The order number | Order emails only |
{order_date} |
The order’s creation date | Order emails only |
The default Subject ([{site_title}] Order ({order_number}) - {order_date}) and heading (Order {order_number}) are built from these. For product or user triggers there is no order, so {order_number} and {order_date} stay empty.
Order shortcodes #
These resolve when the email has an order in context (order and subscription triggers). In a non-order email they return an empty string.
| Shortcode | Returns |
|---|---|
[order_id] |
Internal order ID |
[order_number] |
Order number |
[order_date] |
Order creation date, formatted |
[order_details] |
The full order items table (see attributes below) |
[order_downloads] |
The downloadable-products table |
[order_total] |
Order total |
[order_total_excl_tax] |
Order total minus tax |
[order_total_tax] |
Total tax |
[order_shipping_total] |
Shipping total |
[order_shipping_method] |
Shipping method title |
[order_payment_method_title] |
Payment method label |
[order_payment_method_id] |
Payment gateway ID (for example bacs) |
[order_total_items_count] |
Number of line items |
[order_total_items_qty] |
Total quantity across items |
[order_item_names] |
Comma-separated item names |
[order_item_product_ids] |
Comma-separated product/variation IDs |
[order_item_product_images] |
Product images for the items |
[order_item_meta key="..."] |
A meta value from each item |
[order_billing_address] |
Formatted billing address |
[order_shipping_address] |
Formatted shipping address |
[order_shipping_address_map_url] |
Google Maps URL for the shipping address |
[order_billing_first_name], [order_billing_last_name] |
Billing first/last name |
[order_billing_email], [order_billing_phone] |
Billing email/phone |
[order_customer_note] |
The customer’s checkout note |
[order_customer_order_notes] |
Notes added to the customer |
[order_meta key="..."] |
Any order meta value |
[order_user_id] |
The customer’s user ID |
[order_user_data key="..."] |
A field from the user record (for example user_email) |
[order_user_meta key="..."] |
A user meta value for the order’s customer |
[order_view_url], [order_edit_url] |
Customer view / admin edit URLs |
[order_received_url], [order_cancel_url] |
Order-received and cancel URLs |
[order_checkout_payment_url] |
Pay-for-order URL (useful for unpaid orders) |
[order_func func="..."] |
The result of a WC_Order method (allowlisted, see below) |
User and product shortcodes #
| Shortcode | Returns | Context |
|---|---|---|
[user_prop key="..."] |
A property of the user (for example first_name, user_email) |
User emails |
[generate_coupon_code amount="..."] |
A unique per-customer coupon code | User emails |
[product_func func="..."] |
The result of a WC_Product method (allowlisted, see below) |
Product emails |
General shortcodes #
| Shortcode | Purpose |
|---|---|
[site_title] |
Site title (shortcode form of {site_title}) |
[site_address] |
Site domain |
[if value1="" operator="" value2=""]...[/if] |
Conditional content (see the dedicated guide) |
[translate ...] |
Multilingual content (see the dedicated guide) |
[clear] |
Outputs an empty paragraph, for spacing |
Common attributes #
Most order, user, and product shortcodes route their output through a shared formatter, so they accept the same set of extra attributes:
| Attribute | Effect |
|---|---|
before |
Text printed before the value, only when the value is not empty. |
after |
Text printed after the value, only when the value is not empty. |
format |
Use format="price" to render a number as a formatted price, or any sprintf pattern (for example format="%05d"). |
add |
Adds a number to a numeric value. |
multiply |
Multiplies a numeric value. |
key |
Required by the meta and property shortcodes (order_meta, order_item_meta, order_user_meta, order_user_data, user_prop). |
func |
Required by order_func and product_func (see the allowlist note). |
Example combining several: [order_total format="price" before="Total: "] prints “Total: ” followed by the formatted order total, or nothing at all if there is no order.
[order_details] attributes #
[order_details] renders WooCommerce’s standard order items table and accepts flags to enrich it:
| Attribute | Effect when set to true |
|---|---|
add_product_links |
Links each item name to its product page. |
add_product_images |
Shows the product image next to each item. |
add_product_desc |
Adds each product’s full description. |
add_product_short_desc |
Adds each product’s short description. |
plain_text |
Renders the plain-text version of the table. |
sent_to_admin |
Renders the admin variant (shows admin-only details). |
For example: [order_details add_product_images="true" add_product_links="true"].
The [order_func] and [product_func] allowlist #
[order_func] and [product_func] can call a method on the order or product object, but for security the method must be explicitly allowlisted. On a default install the allowlist is empty, so these two shortcodes return nothing until a developer opts specific methods in through the wpfactory_wc_custom_emails_shortcode_order_func and wpfactory_wc_custom_emails_shortcode_product_func filters. See the Developer Hooks & Filters Reference for the code.
Notes #
- An order shortcode used in a non-order email (and vice versa) returns an empty string rather than an error, so it is safe to include shortcodes that only sometimes apply.
- Shortcode output is filtered to post-safe HTML, so normal formatting survives but disallowed markup is removed.
- A developer can add a prefix to every shortcode tag through the
wpfactory_wc_custom_emails_shortcode_prefixfilter; by default there is no prefix.
Build richer emails #
These shortcodes and placeholders are the building blocks of every template in Additional Custom Emails & Recipients for WooCommerce. Get the plugin to compose emails that pull live data from every order.