Cartoon of Author

@zackeryfretty

Using WooCommerce Sequential Order Numbers & YayMail

🗓

Do you use YayMail? What about WooCommerce Sequential Order Numbers Pro? If so, boy, do I have a post for you!

You've probably noticed that - out of the box at least - YayMail doesn't have support for WooCommerce Sequential Order Numbers, so you're likely sending out emails showing the order's Post ID rather than the actual order number you're using internally.

Luckily these two plugins can be easily integrated with the following snippet (installed either in your functions.php or via Code Snippets):

function zf_sequential_order_yaymail_shortcode(  $shortcode_list, $yaymail_informations, $args = array() ) {
	// Real Order Lookup
	if (isset ($args['order'])) {
		$order = $args['order'];
		$order_id = $order->get_order_number();
		return $order_id;
	}
	
	// YayMail Preview
	return 'PRE_XXXX';
}

add_filter(
	'yaymail_customs_shortcode',
	function( $shortcode_list, $yaymail_informations, $args = array() ) {
			$shortcode_list['[yaymail_custom_shortcode_sequential_order_number]']  = zf_sequential_order_yaymail_shortcode($shortcode_list, $yaymail_informations, $args);
		return $shortcode_list;
	},
	10,
	3
);

Note: You can replace 'PRE_XXXX' with whatever your prefix/suffix template looks like, though, this doesn't actually do anything other than show that text as a placeholder when you're editing the templates.

Once installed you should see the following option under "Custom Shortcodes" when editing a template with YayMail (or just paste this in any location you need it):

[yaymail_custom_shortcode_sequential_order_number]

Using that will display your custom sequential order number instead of the Post ID.

Hopefully that saves you some time! 😁

———