Add booking completed email for users

Hi,
There is already an email in hivepress–> email for vendors when a booking is completed. I would like to write the same email for customer. Can you tell me how to get it in hivepress without going through woocomerce please ?

Many thanks for you feedback

Hi,

Please clarify, do you want to change the Order Completed email?

Hi,
No, I just would like the customer to receive the Order completed email with the same tokens that the Order completed email for vendor.
Is that possible without going through woocomerce beacause the tokens are more limited than hivepress emails.

Many thanks for your feedback

Hi,

I see. There is no such email because all user order updates are sent by WooCommerce. However, as a workaround, we can provide a sample snippet to duplicate the order completed on the customer’s email, but please note that it can require further customization. Let me know if it works for you.

Hi,
That would be great.
Thank you!

If you mean the Order Completed email, please try this sample code snippet:

add_action(
	'hivepress/v1/emails/order_complete/send',
	function( $email ) {
		$tokens = $email->get_tokens();

		if ( ! isset( $tokens['order_number'] ) ) {
			return;
		}

		$order_id = absint( str_replace( '#', '', $tokens['order_number'] ) );

		if ( ! $order_id ) {
			return;
		}

		$order = wc_get_order( $order_id );

		if ( ! $order ) {
			return;
		}

		wp_mail( $order->get_billing_email(), 'email subject here', 'email text here' );
	}
);

It should send an email to the booking user, but please note that it’s not related to bookings and doesn’t contain booking details, it’s related to WooCommerce order which is auto-completed when the booking end date passes. We plan to add separate emails for the booking completion (e.g. to ask users to leave a review).

Hope this helps

Hi,
Many thanks for the snipped code. Is it possible to add a the token %listing_url% in the section ‘email text here’ ? Because when I add the email and send it, %listing_url% remains %listing_url% :
“Please do not hesitate to let a comment to give a feedback : %listing_url%”
Many thanks for your feedback

There’s no listing token by default, but this approach may work:

add_action(
	'hivepress/v1/emails/order_complete/send',
	function( $email ) {
		$tokens = $email->get_tokens();

		if ( ! isset( $tokens['order_number'] ) ) {
			return;
		}

		$order_id = absint( str_replace( '#', '', $tokens['order_number'] ) );

		if ( ! $order_id ) {
			return;
		}

		$order = wc_get_order( $order_id );

		if ( ! $order ) {
			return;
		}

		$item = hivepress()->helper->get_first_array_value( $order->get_items() );

		if ( ! $item ) {
			return;
		}

		$product = $item->get_product();

		if ( ! $product || ! $product->get_parent_id() ) {
			return;
		}

		$listing_url = get_permalink( $product->get_parent_id() );

		wp_mail( $order->get_billing_email(), 'email subject here ' . $listing_url, 'email text here' );
	}
);

Amazing !

I spent the whole day working on something similar, but your solution is much more concise.
Thank you !

1 Like

Hi,
Thank you very much!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.