Class-wc-custom-reminder-email
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
class WC_Reminder_Email extends WC_Email {
public function __construct() {
$this->id = 'wc_reminder_email';
$this->title = 'Herinnering email';
$this->description = 'Een herinnering email wanneer een klant een week lang de labels nog niet heeft ontvangen.';
$this->heading = 'Herinnering Email labels';
$this->subject = 'Herinnering Email labels';
$this->template_html = 'emails/custom-reminder.php';
$this->template_plain = 'emails/plain/custom-reminder.php';
parent::__construct();
$this->recipient = 'support@suiteseven.nl';
if ( ! $this->recipient )
$this->recipient = get_option( 'admin_email' );
}
public function trigger( $order_id ) {
if ( ! $order_id )
return;
$this->object = new WC_Order( $order_id );
$this->recipient = 'luuk@suiteseven.nl';
if ( ! in_array( $this->object->get_shipping_method(), array( 'Three Day Shipping', 'Next Day Shipping' ) ) )
return;
$this->find[] = '{order_date}';
$this->replace[] = date_i18n( woocommerce_date_format(), strtotime( $this->object->order_date ) );
$this->find[] = '{order_number}';
$this->replace[] = $this->object->get_order_number();
if ( ! $this->is_enabled() || ! $this->get_recipient() )
return;
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
}
public function get_content_html() {
ob_start();
woocommerce_get_template( $this->template_html, array(
'order' => $this->object,
'email_heading' => $this->get_heading()
) );
return ob_get_clean();
}
public function get_content_plain() {
ob_start();
woocommerce_get_template( $this->template_plain, array(
'order' => $this->object,
'email_heading' => $this->get_heading()
) );
return ob_get_clean();
}
public function init_form_fields() {
$this->form_fields = array(
'enabled' => array(
'title' => 'Enable/Disable',
'type' => 'checkbox',
'label' => 'Enable this email notification',
'default' => 'yes'
),
'subject' => array(
'title' => 'Subject',
'type' => 'text',
'description' => sprintf( 'This controls the email subject line. Leave blank to use the default subject: <code>%s</code>.', $this->subject ),
'placeholder' => '',
'default' => ''
),
'heading' => array(
'title' => 'Email Heading',
'type' => 'text',
'description' => sprintf( __( 'This controls the main heading contained within the email notification. Leave blank to use the default heading: <code>%s</code>.' ), $this->heading ),
'placeholder' => '',
'default' => ''
),
'email_type' => array(
'title' => 'Email type',
'type' => 'select',
'description' => 'Choose which format of email to send.',
'default' => 'html',
'class' => 'email_type',
'options' => array(
'plain' => __( 'Plain text', 'woocommerce' ),
'html' => __( 'HTML', 'woocommerce' ),
'multipart' => __( 'Multipart', 'woocommerce' ),
)
)
);
}
}