Woocommerce - отправлять уведомления по электронной почте на заказ статуса - PullRequest
0 голосов
/ 25 сентября 2018

Мне нужно создать пользовательские заказы для woocommerce и отправить клиенту уведомления.

Но когда я создаю эти заказы, они появляются на странице заказа, но при активации они не отправляют электронное письмоуведомление клиента.

Например:

Я создал пользовательский заказ "Nota Fiscal" с именем wc-invoice

    function register_invoice_order_status() {
    register_post_status( 'wc-invoice', array(
        'label'                     => 'Nota Fiscal',
        'public'                    => true,
        'exclude_from_search'       => false,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'label_count'               => _n_noop( 'Nota Fiscal <span class="count">(%s)</span>', 'Nota Fiscal <span class="count">(%s)</span>' )
    ) );
}
add_action( 'init', 'register_invoice_order_status' );

// Add to list of WC Order statuses
function add_invoice_to_order_statuses( $order_statuses ) {
    $new_order_statuses = array();
    foreach ( $order_statuses as $key => $status ) {
        $new_order_statuses[ $key ] = $status;
        if ( 'wc-processing' === $key ) {
            $new_order_statuses['wc-invoice'] = 'Nota Fiscal';
        }
    }
    return $new_order_statuses;
}
add_filter( 'wc_order_statuses', 'add_invoice_to_order_statuses' );

// As of WooCommerce 2.3
function so_27112461_woocommerce_email_actions( $actions ){
    $actions[] = 'woocommerce_order_status_wc-invoice';
    return $actions;
}
add_filter( 'woocommerce_email_actions', 'so_27112461_woocommerce_email_actions' );

Я создал классдля WC_Email

class WC_Email_Invoice_Order extends WC_Email { 
public function __construct() {

        // set ID, this simply needs to be a unique name
        $this->id = 'wc_invoice';

        // this is the title in WooCommerce Email settings
        $this->title = 'Nota Fiscal';

        // this is the description in WooCommerce email settings
        $this->description = 'Confirmando envio de Nota Fiscal';

        // these are the default heading and subject lines that can be overridden using the settings
        $this->heading = ' Nota Fiscal';
        $this->subject = ' Nota Fiscal';

        // these define the locations of the templates that this email should use, we'll just use the new order template since this email is similar
        $this->template_html  = 'emails/customer-confirmed-order.php';
        $this->template_plain = 'emails/plain/admin-new-order.php';

        // Trigger on confirmed orders
        add_action( 'woocommerce_order_status_pending_to_wc_invoice', array( $this, 'trigger' ) );
        add_action( 'woocommerce_order_status_processing_to_wc_invoice', array( $this, 'trigger' ) );

        // Call parent constructor to load any other defaults not explicity defined here
        parent::__construct();

        // this sets the recipient to the settings defined below in init_form_fields()
        $this->recipient = $this->get_option( 'recipient' );

        // if none was entered, just use the WP admin email as a fallback
        if ( ! $this->recipient )
            $this->recipient = get_option( 'admin_email' );
    }

Когда вы изменяете статус на Счет, он не отправляет уведомление на электронную почту. изменить порядок для Nota Fiscal

Что может происходить?

...