id = StockAlerts::EMAIL_ID; $this->customer_email = true; $this->title = I18n::t( 'Back in stock' ); $this->description = I18n::t( 'Sent once to a shopper who asked to be told when an out-of-stock product is available again.' ); $this->placeholders = array( '{product_name}' => '' ); parent::__construct(); } public function get_default_subject() { return I18n::t( '{product_name} is back in stock at {site_title}' ); } public function get_default_heading() { return I18n::t( 'It is back in stock' ); } public function trigger( string $recipient, \WC_Product $product ): bool { $this->setup_locale(); $this->recipient = $recipient; $this->product = $product; $this->placeholders['{product_name}'] = $product->get_name(); $sent = $this->is_enabled() && $this->get_recipient() ? (bool) $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ) : false; $this->restore_locale(); return $sent; } public function get_content_html() { ob_start(); wc_get_template( 'emails/email-header.php', array( 'email_heading'=>$this->get_heading(), 'email'=>$this ) ); echo '

' . esc_html( sprintf( I18n::t( 'Good news: %s is available again.' ), $this->product ? $this->product->get_name() : '' ) ) . '

'; if ( $this->product ) { echo '

' . esc_html( I18n::t( 'View the product' ) ) . '

'; } echo '

' . esc_html( I18n::t( 'You asked us to email you once about this product. We will not email you about it again.' ) ) . '

'; wc_get_template( 'emails/email-footer.php', array( 'email'=>$this ) ); return (string) ob_get_clean(); } public function get_content_plain() { $name = $this->product ? $this->product->get_name() : ''; return sprintf( I18n::t( 'Good news: %s is available again.' ), $name ) . "\n\n" . ( $this->product ? $this->product->get_permalink() . "\n\n" : '' ) . I18n::t( 'You asked us to email you once about this product. We will not email you about it again.' ) . "\n"; } }