Custom shortcode

You can also create your own shortcodes using filter by adding shortcode name with prefix: yaymail_custom_shortcode_['name'] in file functions.php of your site's theme.

Note: Custom shortcodes only work in emails when you place an actual order, but do not work when you send test emails.

Example 1:

You can copy the code from here:

add_filter(
    'yaymail_customs_shortcode',
    function( $shortcode_list, $yaymail_informations, $args = array() ) {
        $shortcode_list['[yaymail_custom_shortcode_new_order]']        = 'Custom shortcode test New order';
        $shortcode_list['[yaymail_custom_shortcode_processing_order]'] = 'Custom shortcode test Processing order';
        $shortcode_list['[yaymail_custom_shortcode_order_on_hold]']    = 'Custom shortcode test Order on hold';
        return $shortcode_list;
    },
    10,
    3
);

Example 2:

You can copy the code from here:

function test_shortcode1(  $shortcode_list, $yaymail_informations, $args = array() ) {
	//It only runs when tested with real order
	if (isset ($args['order'])) {
		$order = $args['order'];
		$order_id = $order->get_id();
		return $order_id;
	}
	
	// in Yaymail will show it
	return 'test_shortcode';
}

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

You can see your custom shortcodes in the list here.

Last updated