$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>functions - change billing and shipping address 1 and 2 field placeholders|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

functions - change billing and shipping address 1 and 2 field placeholders

matteradmin9PV0评论
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 6 years ago.

Improve this question

I'm trying to change the placeholder text for the billing and shipping address 1 and address 2 fields but I can't get it to change at all. This is what I have for billing address 1

// This function sets the address 1 placeholder
add_filter( 'woocommerce_checkout_fields', 'uwc_new_address_one_placeholder' );
function uwc_new_address_one_placeholder($fields){

        $fields['billing']['billing_address_1']['placeholder'] = 'over the hill';

    return $fields;
}

This works for every other field except for address 1 and 2. What am I doing wrong?

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 6 years ago.

Improve this question

I'm trying to change the placeholder text for the billing and shipping address 1 and address 2 fields but I can't get it to change at all. This is what I have for billing address 1

// This function sets the address 1 placeholder
add_filter( 'woocommerce_checkout_fields', 'uwc_new_address_one_placeholder' );
function uwc_new_address_one_placeholder($fields){

        $fields['billing']['billing_address_1']['placeholder'] = 'over the hill';

    return $fields;
}

This works for every other field except for address 1 and 2. What am I doing wrong?

Share Improve this question asked Feb 20, 2019 at 6:43 John CookJohn Cook 673 silver badges9 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

Prior to the address fields being passed through the woocommerce_checkout_fields hook, they are retrieved by WC_Countries::get_address_fields(), and inside that function there is a comment before its filter that reads:

Important note on this filter: Changes to address fields can and will be overridden by the woocommerce_default_address_fields. The locales/default locales apply on top based on country selection. If you want to change things like the required status of an address field, filter woocommerce_default_address_fields instead.

It seems likely to me that the same issue would affect the woocommerce_checkout_fields filter.

So my recommendation would be to use the woocommerce_default_address_fields filter instead:

function uwc_new_address_one_placeholder( $fields ) {
    $fields['address_1']['placeholder'] = 'over the hill';

    return $fields;
}
add_filter( 'woocommerce_default_address_fields', 'uwc_new_address_one_placeholder' );

Note that this filter applies to both shipping and billing addresses, and should not require the shipping_ or billing_ prefixes on the field names.

Post a comment

comment list (0)

  1. No comments so far