Show a placeholder value when the billing email field is empty in WooCommerce

Show a placeholder value when the billing email field is empty in WooCommerce.

Snippet Type

Execute on Child Sites

Snippet

add_filter( 'woocommerce_checkout_fields' , 'conditional_checkout_billing_email_placeholder', 20, 1 );

function conditional_checkout_billing_email_placeholder( $fields ) {
    $billing_email = WC()->customer->get_billing_email();

    if ( empty($billing_email) ) {
        $fields['billing']['billing_email']['placeholder'] = __('Your Email Address');
    }
    return $fields;
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.