Set the order used for email previews

Replace the example ID with an order that contains representative data. The guard keeps the existing preview data when the order cannot be loaded.

Developer note:

Add custom PHP in a small custom plugin or child theme, and test it on a staging site before production. This example requires ongoing maintenance when extension APIs change.

functions.php

<?php

add_filter( 'automatewoo/preview_data_layer', 'my_store_automatewoo_preview_order' );

/**
 * Set the order and customer used in workflow previews.
 *
 * @param array $data Preview data.
 * @return array
 */
function my_store_automatewoo_preview_order( $data ) {
	$order = wc_get_order( 123 );

	if ( ! $order ) {
		return $data;
	}

	$customer = AutomateWoo\Customer_Factory::get_by_order( $order );

	if ( ! $customer ) {
		return $data;
	}

	$data['order']    = $order;
	$data['customer'] = $customer;

	return $data;
}
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.