• Resolved Mario Beach

    (@mariobeach)


    Hi, I’m trying to update the placeholder on some checkout fields. There is a filter for that, it should be pretty simple.

    add_filter(‘woocommerce_checkout_fields’, ‘wea_override_address_fields’);
    function wea_override_address_fields( $fields ) {
    $fields[‘billing’][‘billing_address_1’][‘placeholder’] = ‘House, School or Business number and stree address’;
    return $fields;
    }

    Unfortunately, it does work but only for a brief moment, as soon as the ajax updates the form, I’m back with the original placeholders. Any idea how to resolve? I’m running the latest woocommerce (3.2.3) so I have no idea if it use to work or not.

    Here’s a screencast of my checkout page here. I hit refresh and if you look closely at around 0.05s the placeholder of the address gets updated but right after when ajax kicks in, the form refreshes and the placeholder is back to original. https://www.screencast.com/t/A7TnY8yU3

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • Looks like the docs have it wrong. You need:

    add_filter('woocommerce_default_address_fields', 'wea_override_address_fields');
    function wea_override_address_fields( $fields ) {
    $fields['address_1']['placeholder'] = 'House, School or Business number and street address';
    return $fields;
    }
    • This reply was modified 7 years, 4 months ago by superkot. Reason: tested & works
    Thread Starter Mario Beach

    (@mariobeach)

    Thanks @superkot, works beautifully! I noticed that $fields[‘address_1’] takes care of both billing_address_1 and shipping_address_1. In my case it’s perfect, I actually wanted to update both but what if I wanted to change only billing or only shipping?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘woocommerce_checkout_fields filter wiped out by ajax’ is closed to new replies.