Leave a Reply

1 comment

  1. If you mean in My account pages for Billing and Shipping form, the only filter hook (that I know) that could do the trick is:

    add_filter( 'woocommerce_form_field_args', 'custom_form_field_args', 10, 3 );
    function custom_form_field_args( $args, $key, $value ) { 
        // your code 
        return $args;
    };
    

    It is located in wc-template-functions.php on line 1734, triggered by woocommerce_form_field() function in woocommerce templates under my_account subfolder, form-edit-address.php file (displaying the form fields) .


    This are the default $args you can use to target the changes you want to do inside your filter function:

    $defaults = array(
        'type'              => 'text',
        'label'             => '',
        'description'       => '',
        'placeholder'       => '',
        'maxlength'         => false,
        'required'          => false,
        'autocomplete'      => false,
        'id'                => $key,
        'class'             => array(),
        'label_class'       => array(),
        'input_class'       => array(),
        'return'            => false,
        'options'           => array(),
        'custom_attributes' => array(),
        'validate'          => array(),
        'default'           => '',
    );
    

    NOTE: With some changes made by Stone it’s working. (see the comment).

    USE:
    You could use ‘placeholder’ this way to target each placeholder you need to change:

    if ( $args['id'] == 'your_slug1' ) {
        $args['placeholder'] = 'your_new_placeholder1';
    } elseif ( $args['id'] == 'your_slug2' ) {
        $args['placeholder'] = 'your_new_placeholder2';
    } // elseif … and go on
    

    The placeholders are generally the same for billing and shipping address… So your code will be like:

    add_filter( 'woocommerce_form_field_args', 'custom_form_field_args', 10, 3 );
    function custom_form_field_args( $args, $key, $value ) { 
        if ( $args['id'] == 'your_slug1' ) {
            $args['placeholder'] = 'your_new_placeholder1';
        } elseif ( $args['id'] == 'your_slug2' ) {
            $args['placeholder'] = 'your_new_placeholder2';
        } // elseif … and go on 
    
        return $args;
    };