如何在用户使用Woocommerce Booking进行预订时发送电子邮件

I want to notify both user and admin through an email when user made a booking in WooCommerce Bookings. Now it is sending mail only to admin to confirm booking.

Can anyone give me right direction, as how to achieve this. Thanks.

It's a piece of cake.

function my_awesome_shipping_notification($order_id, $checkout = null) {
    global $woocommerce;

    $order = new WC_Order($order_id);

    if ($order->status === 'on-hold') {

        // Create a mailer
        $mailer = $woocommerce->mailer();

        $message_body = __('Order placed: Waiting for confirmation.', 'text_domain');

        $message = $mailer->wrap_message(
                // Message head and message body.
                sprintf(__('Order %s ready for shipping', 'text_domain'), $order->get_order_number()), $message_body);

        // Client email, email subject and message.
        $result = $mailer->send($order->billing_email, sprintf(__('Order %s received', 'text_domain'), $order->get_order_number()), $message);

        //error_log( $result );
    }
}

add_action('woocommerce_order_status_changed', 'my_awesome_shipping_notification');

Hope this helps.

Reference: [https://docs.woocommerce.com/document/bookings-action-and-filter-reference/][1]

read the plugin documentation!

WooCommerce Bookings has five email alerts that are handled for you automatically. You can edit all emails sent to customers at: WooCommerce > Settings > Emails. They are:

  1. New Booking: Emails are sent to the admin when a new booking is created.
  2. Booking Confirmed: Emails are sent when a booking is confirmed.
  3. Booking Reminder: Emails are sent to the customer one day prior to their booking to remind them of an upcoming booking.
  4. Booking Notification: Notification emails are sent manually from WooCommerce > Bookings > Send Notification.
  5. Booking Cancelled: Emails are sent when a booking is cancelled.

source