@Ofelion

Как выбрать конкретный шаблон письма WooCommerce для отправки клиенту?

Привет всем!
Реализовал функционал - при отмене заказа из админки в WooCommerce клиенту отправляется письмо с уведомлением об отмене заказа. Проблема - как в функцию mail() передать шаблон нужного письма в параметре? Код пишу в файле public_html/wp-content/plugins/woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-actions.php , шаблоны писем в этой папке: \public_html\wp-content\plugins\woocommerce\templates\emails\admin-cancelled-order.php
  • Вопрос задан
  • 113 просмотров
Решения вопроса 1
@Ofelion Автор вопроса
Ответ намного проще, чем может показаться, всего несколько строчек в файле class-wc-email-cancelled-order.php

public function trigger( $order_id, $order = false ) {
            $this->setup_locale();
            $data = $order->get_data(); // инициализируем заказ
            $userEmail = $data['billing']['email']; // получаем email клиента
            if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
                $order = wc_get_order( $order_id );
            }
 
            if ( is_a( $order, 'WC_Order' ) ) {
                $this->object                                    = $order;
                $this->placeholders['{order_date}']              = wc_format_datetime( $this->object->get_date_created() );
                $this->placeholders['{order_number}']            = $this->object->get_order_number();
                $this->placeholders['{order_billing_full_name}'] = $this->object->get_formatted_billing_full_name();
            }
 
            if ( $this->is_enabled() && $this->get_recipient() ) {
                $this->send( $this->get_recipient().','.$userEmail, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );  //подставляем его get_recipient().','.$userEmail
            }
 
            $this->restore_locale();
        }
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы