The token "%user%" and "%listing%" don't work

For me it works, at last. :sunglasses: :+1:
Sorry for the misunderstanding @ihor & @andrii.

Level 1 :
So let’s start simple

add_filter(
	'hivepress/v1/emails/order_receive',
	function( $email ) {
		$email['tokens']['test'] = "Hello Bill";
		return $email;
	}
);

In your “order received” email template, use %test%
it should display “Hello Bill”.

Level 2 :
(expert mode)

add_filter(
	'hivepress/v1/emails/order_receive',
	function( $email ) {
		$order = wc_get_order( absint( str_replace( '#', '', $email['tokens']['order_number'] ) ) );

		if ( $order && $order->get_customer_id() ) {
			$email['tokens']['customer'] = \HivePress\Models\User::query()->get_by_id( $order->get_customer_id() );
		}

		return $email;
	}
);

In your “order received” email template, use %customer.username%
it should display the name of this order’s customer, but you could access any other attribute available in the object.

Hope this helps and thank you guys !

1 Like