plugin_slug; } /** * Set email defaults * * @since 1.0 */ public function __construct() { $this->id = 'Affinite_alert_customer_save_email'; $this->customer_email = true; $this->title = esc_html__('Stock alert customer save info', 'affinite-back-in-stock'); $this->description = esc_html__('Stock alert customer save info', 'affinite-back-in-stock'); $this->heading = esc_html__('Stock alert customer save info', 'affinite-back-in-stock'); $this->product = null; // 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 = 'stock-alert-customer-save-email.php'; $this->template_plain = 'stock-alert-customer-save-email-plain.php'; $this->templates = array( 'stock-alert-customer-save-email.php', 'stock-alert-customer-save-email-plain.php' ); // Call parent constructor to load any other defaults not explicity defined here parent::__construct(); } /** * Get email subject. * * @since 1.0 * @return string */ public function get_default_subject() { return esc_html__('Stock alert info from {site_title}', 'affinite-back-in-stock'); } /** * Determine if the email should actually be sent and setup email merge variables * * @since 1.0 * @param int $order_id */ public function trigger( $product_id, $email ) { $this->product = wc_get_product( $product_id ); if ( ! $this->is_enabled() ) { return; } $this->recipient = $email; $recipients = $this->get_recipient(); return $this->send( $recipients, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); } /** * get_content_html function. * * @since 0.1 * @return string */ public function get_content_html() { return wc_get_template_html( $this->template_html, array( 'product' => $this->product, 'email_heading' => $this->get_heading(), 'sent_to_admin' => false, 'plain_text' => false, 'email' => $this, ) ); } /** * get_content_plain function. * * @since 0.1 * @return string */ public function get_content_plain() { return wc_get_template_html( $this->template_plain, array( 'product' => $this->product, 'email_heading' => $this->get_heading(), 'sent_to_admin' => false, 'plain_text' => true, 'email' => $this, ) ); } /** * Initialise settings form fields. */ public function init_form_fields() { $this->form_fields = array( 'enabled' => array( 'title' => esc_html__( 'Enable/Disable', 'affinite-back-in-stock' ), 'type' => 'checkbox', 'label' => esc_html__( 'Enable this email notification', 'affinite-back-in-stock' ), 'default' => 'yes', ), 'subject' => array( 'title' => esc_html__( 'Subject', 'affinite-back-in-stock' ), 'type' => 'text', 'desc_tip' => true, /* translators: %s: list of placeholders */ 'description' => sprintf( esc_html__( 'Available placeholders: %s', 'affinite-back-in-stock' ), '{site_title}, {order_date}, {order_number}' ), 'placeholder' => $this->get_default_subject(), 'default' => esc_html__( 'Stock alert info from {site_title}', 'affinite-back-in-stock' ), ), 'heading' => array( 'title' => esc_html__( 'Email heading', 'affinite-back-in-stock' ), 'type' => 'text', 'desc_tip' => true, /* translators: %s: list of placeholders */ 'description' => sprintf( esc_html__( 'Available placeholders: %s', 'affinite-back-in-stock' ), '{site_title}, {order_date}, {order_number}' ), 'placeholder' => $this->get_default_heading(), 'default' => esc_html__( 'Product stock alert', 'affinite-back-in-stock' ), ), 'email_type' => array( 'title' => esc_html__( 'Email type', 'affinite-back-in-stock' ), 'type' => 'select', 'description' => esc_html__( 'Choose which format of email to send.', 'affinite-back-in-stock' ), 'default' => 'html', 'class' => 'email_type wc-enhanced-select', 'options' => $this->get_email_type_options(), 'desc_tip' => true, ), ); } } // end class