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

标签 php wordpress woocommerce email-notifications woocommerce-bookings

当用户在 WooCommerce Bookings 进行预订时,我想通过电子邮件通知双方 用户和管理员 。 现在它只向管理员发送邮件以确认预订。

任何人都可以给我正确的方向,以及如何实现这一目标。 谢谢。

最佳答案

这是小菜一碟。

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');

希望这对您有所帮助。

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

关于php - 用户使用 Woocommerce Booking 进行预订时如何发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39890277/

相关文章:

php - 如何在 PHP 中使用 RegexIterator

php - 如何在@之后获取电子邮件的最后一个值

wordpress - 页面显示wordpress中的所有页面内容

php - wordpress cron 作业是顺序执行还是并行执行?

wordpress - 将 CSS 类添加到具有(或基于)产品类别的 WooCommerce 购物车项目

php - PDO MySQL 检查数据库是否存在

php - mysql 为一个由 终止的 csv 字段和另一个由 终止的 csv 字段加载数据本地文件;

json - 使用 Wordpress JSON API 获取自定义字段(图片)

php - 通过 WooCommerce 3+ 中特定类别的 Hook 更改产品价格

php - 在 Woocommerce 单一产品页面中显示特定产品标签的自定义内容