WC_Email_Customer_Abandoned_Cart_Recovery::init_form_fields
Initialise settings form fields.
Adds an automated field on top of the standard WC_Email fields so merchants can choose between scheduled automatic sends and manual-only dispatch.
Method of the class: WC_Email_Customer_Abandoned_Cart_Recovery{}
No Hooks.
Returns
null. Nothing (null).
Usage
$WC_Email_Customer_Abandoned_Cart_Recovery = new WC_Email_Customer_Abandoned_Cart_Recovery(); $WC_Email_Customer_Abandoned_Cart_Recovery->init_form_fields(): void;
WC_Email_Customer_Abandoned_Cart_Recovery::init_form_fields() WC Email Customer Abandoned Cart Recovery::init form fields code WC 11.0.0
public function init_form_fields(): void {
$placeholder_text = sprintf(
/* translators: %s: list of placeholders */
__( 'Available placeholders: %s', 'woocommerce' ),
'<code>' . implode( '</code>, <code>', array_map( 'esc_html', array_keys( $this->placeholders ) ) ) . '</code>'
);
$active_handlers = self::get_active_recovery_handlers();
$enabled_default = empty( $active_handlers ) ? 'yes' : 'no';
$enabled_description = empty( $active_handlers )
? ''
: sprintf(
/* translators: %s: comma-separated list of detected plugins that already handle abandoned cart recovery (e.g. "AutomateWoo, MailPoet"). */
__( '%s is active on this site and already handles abandoned cart recovery. We\'ve turned this off so customers don\'t receive duplicate emails. Enable anyway if you want WooCommerce to handle recovery instead.', 'woocommerce' ),
implode( ', ', $active_handlers )
);
$this->form_fields = array(
'enabled' => array(
'title' => __( 'Enable/Disable', 'woocommerce' ),
'type' => 'checkbox',
'label' => __( 'Enable this email notification', 'woocommerce' ),
'description' => $enabled_description,
'default' => $enabled_default,
'desc_tip' => '' !== $enabled_description,
),
'automated' => array(
'title' => __( 'Send automatically', 'woocommerce' ),
'type' => 'checkbox',
'label' => __( 'Schedule the recovery email to send 2 hours after a checkout is abandoned', 'woocommerce' ),
'description' => __( 'When disabled, the email is only sent when you trigger it manually from the order edit page.', 'woocommerce' ),
'default' => 'no',
'desc_tip' => true,
),
'subject' => array(
'title' => __( 'Subject', 'woocommerce' ),
'type' => 'text',
'desc_tip' => true,
'description' => $placeholder_text,
'placeholder' => $this->get_default_subject(),
'default' => '',
),
'heading' => array(
'title' => __( 'Email heading', 'woocommerce' ),
'type' => 'text',
'desc_tip' => true,
'description' => $placeholder_text,
'placeholder' => $this->get_default_heading(),
'default' => '',
),
'additional_content' => array(
'title' => __( 'Additional content', 'woocommerce' ),
'description' => __( 'Text to appear below the main email content.', 'woocommerce' ) . ' ' . $placeholder_text,
'css' => 'width:400px; height: 75px;',
'placeholder' => __( 'N/A', 'woocommerce' ),
'type' => 'textarea',
'default' => $this->get_default_additional_content(),
'desc_tip' => true,
),
'email_type' => array(
'title' => __( 'Email type', 'woocommerce' ),
'type' => 'select',
'description' => __( 'Choose which format of email to send.', 'woocommerce' ),
'default' => 'html',
'class' => 'email_type wc-enhanced-select',
'options' => $this->get_email_type_options(),
'desc_tip' => true,
),
);
}