Start a free 14-day trial by December 1 on a wide range of WooCommerce Marketplace extensions and themes. Explore products

Customize a Purolator customer order email

Add a message to the customer’s completed order email when the order uses Purolator. This example displays a separate line before the order table in both HTML and plain text.

Note:

This is a developer-level doc. If you are unfamiliar working with code and resolving potential conflicts, we recommend you work with a Woo Agency Partner for larger projects, or find a WooCommerce developer on Codeable for smaller customization work. We are unable to provide support for customization under our Support Policy.

Before you start

↑ Back to top

Use a test store with Purolator Shipping Method 3.3.6 active, a fictional order, and a site-specific plugin for custom PHP. Use a preview environment with carrier requests intercepted because the extension can process shipments when WooCommerce renders an order email.

Add the customer message

↑ Back to top

Add this callback to your site-specific plugin. Replace the sample message with the line you want customers to see.

add_action(
	'woocommerce_email_before_order_table',
	static function ( WC_Order $order, bool $sent_to_admin, bool $plain_text, WC_Email $email ): void {
		if ( $sent_to_admin || 'customer_completed_order' !== $email->id ) {
			return;
		}

		foreach ( $order->get_shipping_methods() as $method ) {
			if ( 'purolator' !== $method->get_method_id() ) {
				continue;
			}

			$message = 'Your order is shipping with Purolator.';
			if ( $plain_text ) {
				echo "\n" . esc_html( $message ) . "\n";
			} else {
				echo '<p>' . esc_html( $message ) . '</p>';
			}
			break;
		}
	},
	20,
	4
);

Verify your message

↑ Back to top

Preview the completed order email for a fixture order with Purolator shipping. Check both HTML and plain-text formats, then preview a completed order with another shipping method and confirm that the message only appears for the Purolator order. If the message is missing, check the email type and the shipping method stored on the order. To undo the change, remove the callback.

Questions and support

↑ Back to top

Something missing from this documentation? Still have questions and need assistance?

  • If you have a question about a specific extension or theme you’d like to purchase, contact us to get answers.
  • If you already purchased this product and need some assistance, get in touch with a Happiness Engineer via our support page and select this product’s name from the Product dropdown.

Related Products

Accept payments online using the Moneris payment gateway.

WooCommerce Subscriptions is a WooCommerce extension that lets customers subscribe to your products or...

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.