id = 'email';
$this->label = __( 'Emails', 'woocommerce' );
add_action( 'woocommerce_admin_field_email_notification', array( $this, 'email_notification_setting' ) );
parent::__construct();
}
/**
* Get sections.
*
* @return array
*/
public function get_sections() {
$sections = array(
'' => __( 'Email options', 'woocommerce' ),
);
return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
}
/**
* Get settings array.
*
* @return array
*/
public function get_settings() {
$desc_help_text = sprintf(
/* translators: %1$s: Link to WP Mail Logging plugin, %2$s: Link to Email FAQ support page. */
__( 'To ensure your store’s notifications arrive in your and your customers’ inboxes, we recommend connecting your email address to your domain and setting up a dedicated SMTP server. If something doesn’t seem to be sending correctly, install the WP Mail Logging Plugin or check the Email FAQ page.', 'woocommerce' ),
'https://wordpress.org/plugins/wp-mail-logging/',
'https://docs.woocommerce.com/document/email-faq'
);
$settings = apply_filters(
'woocommerce_email_settings',
array(
array(
'title' => __( 'Email notifications', 'woocommerce' ),
/* translators: %s: help description with link to WP Mail logging and support page. */
'desc' => sprintf( __( 'Email notifications sent from WooCommerce are listed below. Click on an email to configure it.
%s', 'woocommerce' ), $desc_help_text ),
'type' => 'title',
'id' => 'email_notification_settings',
),
array( 'type' => 'email_notification' ),
array(
'type' => 'sectionend',
'id' => 'email_notification_settings',
),
array(
'type' => 'sectionend',
'id' => 'email_recipient_options',
),
array(
'title' => __( 'Email sender options', 'woocommerce' ),
'type' => 'title',
'desc' => '',
'id' => 'email_options',
),
array(
'title' => __( '"From" name', 'woocommerce' ),
'desc' => __( 'How the sender name appears in outgoing WooCommerce emails.', 'woocommerce' ),
'id' => 'woocommerce_email_from_name',
'type' => 'text',
'css' => 'min-width:400px;',
'default' => esc_attr( get_bloginfo( 'name', 'display' ) ),
'autoload' => false,
'desc_tip' => true,
),
array(
'title' => __( '"From" address', 'woocommerce' ),
'desc' => __( 'How the sender email appears in outgoing WooCommerce emails.', 'woocommerce' ),
'id' => 'woocommerce_email_from_address',
'type' => 'email',
'custom_attributes' => array(
'multiple' => 'multiple',
),
'css' => 'min-width:400px;',
'default' => get_option( 'admin_email' ),
'autoload' => false,
'desc_tip' => true,
),
array(
'type' => 'sectionend',
'id' => 'email_options',
),
array(
'title' => __( 'Email template', 'woocommerce' ),
'type' => 'title',
/* translators: %s: Nonced email preview link */
'desc' => sprintf( __( 'This section lets you customize the WooCommerce emails. Click here to preview your email template.', 'woocommerce' ), wp_nonce_url( admin_url( '?preview_woocommerce_mail=true' ), 'preview-mail' ) ),
'id' => 'email_template_options',
),
array(
'title' => __( 'Header image', 'woocommerce' ),
'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'woocommerce' ),
'id' => 'woocommerce_email_header_image',
'type' => 'text',
'css' => 'min-width:400px;',
'placeholder' => __( 'N/A', 'woocommerce' ),
'default' => '',
'autoload' => false,
'desc_tip' => true,
),
array(
'title' => __( 'Footer text', 'woocommerce' ),
/* translators: %s: Available placeholders for use */
'desc' => __( 'The text to appear in the footer of all WooCommerce emails.', 'woocommerce' ) . ' ' . sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title} {site_url}' ),
'id' => 'woocommerce_email_footer_text',
'css' => 'width:400px; height: 75px;',
'placeholder' => __( 'N/A', 'woocommerce' ),
'type' => 'textarea',
'default' => '{site_title} — Built with {WooCommerce}',
'autoload' => false,
'desc_tip' => true,
),
array(
'title' => __( 'Base color', 'woocommerce' ),
/* translators: %s: default color */
'desc' => sprintf( __( 'The base color for WooCommerce email templates. Default %s.', 'woocommerce' ), '#96588a
' ),
'id' => 'woocommerce_email_base_color',
'type' => 'color',
'css' => 'width:6em;',
'default' => '#96588a',
'autoload' => false,
'desc_tip' => true,
),
array(
'title' => __( 'Background color', 'woocommerce' ),
/* translators: %s: default color */
'desc' => sprintf( __( 'The background color for WooCommerce email templates. Default %s.', 'woocommerce' ), '#f7f7f7
' ),
'id' => 'woocommerce_email_background_color',
'type' => 'color',
'css' => 'width:6em;',
'default' => '#f7f7f7',
'autoload' => false,
'desc_tip' => true,
),
array(
'title' => __( 'Body background color', 'woocommerce' ),
/* translators: %s: default color */
'desc' => sprintf( __( 'The main body background color. Default %s.', 'woocommerce' ), '#ffffff
' ),
'id' => 'woocommerce_email_body_background_color',
'type' => 'color',
'css' => 'width:6em;',
'default' => '#ffffff',
'autoload' => false,
'desc_tip' => true,
),
array(
'title' => __( 'Body text color', 'woocommerce' ),
/* translators: %s: default color */
'desc' => sprintf( __( 'The main body text color. Default %s.', 'woocommerce' ), '#3c3c3c
' ),
'id' => 'woocommerce_email_text_color',
'type' => 'color',
'css' => 'width:6em;',
'default' => '#3c3c3c',
'autoload' => false,
'desc_tip' => true,
),
array(
'type' => 'sectionend',
'id' => 'email_template_options',
),
array(
'title' => __( 'Store management insights', 'woocommerce' ),
'type' => 'title',
'id' => 'email_merchant_notes',
),
array(
'title' => __( 'Enable email insights', 'woocommerce' ),
'desc' => __( 'Receive email notifications with additional guidance to complete the basic store setup and helpful insights', 'woocommerce' ),
'id' => 'woocommerce_merchant_email_notifications',
'type' => 'checkbox',
'checkboxgroup' => 'start',
'default' => 'no',
'autoload' => false,
),
array(
'type' => 'sectionend',
'id' => 'email_merchant_notes',
),
)
);
return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings );
}
/**
* Output the settings.
*/
public function output() {
global $current_section;
// Define emails that can be customised here.
$mailer = WC()->mailer();
$email_templates = $mailer->get_emails();
if ( $current_section ) {
foreach ( $email_templates as $email_key => $email ) {
if ( strtolower( $email_key ) === $current_section ) {
$email->admin_options();
break;
}
}
} else {
$settings = $this->get_settings();
WC_Admin_Settings::output_fields( $settings );
}
}
/**
* Save settings.
*/
public function save() {
global $current_section;
if ( ! $current_section ) {
WC_Admin_Settings::save_fields( $this->get_settings() );
} else {
$wc_emails = WC_Emails::instance();
if ( in_array( $current_section, array_map( 'sanitize_title', array_keys( $wc_emails->get_emails() ) ), true ) ) {
foreach ( $wc_emails->get_emails() as $email_id => $email ) {
if ( sanitize_title( $email_id ) === $current_section ) {
do_action( 'woocommerce_update_options_' . $this->id . '_' . $email->id );
}
}
} else {
do_action( 'woocommerce_update_options_' . $this->id . '_' . $current_section );
}
}
}
/**
* Output email notification settings.
*/
public function email_notification_setting() {
// Define emails that can be customised here.
$mailer = WC()->mailer();
$email_templates = $mailer->get_emails();
?>
' . esc_html( $column ) . ' | '; } ?>||||
---|---|---|---|---|
' . esc_html( $email->get_title() ) . ' ' . wc_help_tip( $email->get_description() ) . ' | '; break; case 'recipient': echo '' . esc_html( $email->is_customer_email() ? __( 'Customer', 'woocommerce' ) : $email->get_recipient() ) . ' | '; break; case 'status': echo ''; if ( $email->is_manual() ) { echo '' . esc_html__( 'Manual', 'woocommerce' ) . ''; } elseif ( $email->is_enabled() ) { echo '' . esc_html__( 'Yes', 'woocommerce' ) . ''; } else { echo '-'; } echo ' | '; break; case 'email_type': echo '' . esc_html( $email->get_content_type() ) . ' | '; break; case 'actions': echo '' . esc_html__( 'Manage', 'woocommerce' ) . ' | '; break; default: do_action( 'woocommerce_email_setting_column_' . $key, $email ); break; } } echo '