• Resolved fabio323ti

    (@fabio323ti)


    i need to display some usermeta in default address template..
    according to wc docs.. the code in function.php to override and change thems looks like this

    // Billing and Shipping fields on my account edit-addresses and checkout
    add_filter( 'woocommerce_default_address_fields' , 'custom_override_default_address_fields' );
    function custom_override_default_address_fields( $fields ) {
        $fields['first_name']['label'] = 'First name';
        $fields['last_name']['label'] = 'Last name';
        // ect ect 
        return $fields;
    }

    in my case this have no effect on frontend.. i can’t understand why.
    im using elementor with “The7 theme”

    somone can help me to solve?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Vijay Hardaha

    (@vijayhardaha)

    Please describe what usermeta you’re trying to display and where you’re adding this information. also share the complete code you’re using.

    Thread Starter fabio323ti

    (@fabio323ti)

    Thanks, for reply, before add usermeta in the code i tryed the code as above to test if its works… but this have no effect on front-end..
    i also disabled some extra plugin but this not solve..

    the whole snippet hane no front-end effect.
    i see old layout default address

    anyway the full function id used is this:

    add_filter( 'woocommerce_default_address_fields' , 'custom_override_default_address_fields' );
    function custom_override_default_address_fields( $fields ) {
        $fields['first_name']['label'] = 'First name';
        $fields['last_name']['label'] = 'Last name';
        $fields['company']['label'] = 'Company name';
        $fields['postcode']['label'] = 'Postcode';
        $fields['piva']['label']  = "Partita Iva";
        $fields['sdi']['label'] = "Sdi";
        $fields['address_1']['label'] = 'Street address';
        $fields['address_2']['label'] = 'Apartment, unit, etc.';
        $fields['city']['label'] = 'City';
        $fields['country']['label'] = 'Country';
        $fields['state']['label'] = 'County/State';
    
        return $fields;
    }

    as you can see “piva” is > billing_piva and “sdi” is billing_sdi
    in my-address-edit and checkout i see them and edits..

    my needed is to display in default address my account page.

    hope its more clear

    Vijay Hardaha

    (@vijayhardaha)

    I think you’re trying to add extra custom checkout fields.

    You need to follow this documentation for adding custom checkout fields https://woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/

    Or you can use any Custom checkout field Editor plugin.

    You can’t just add labels to add new fields. for adding new fields you add to add proper field array. read the documentation properly.

    Thanks

    Thread Starter fabio323ti

    (@fabio323ti)

    im already using checkout field editor,, as i wrote i can edit these fields in checkout end adit-address forms all is working

    is the default address label that now show me extra fields

    Mirko P.

    (@rainfallnixfig)

    Hello @fabio323ti

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook Community group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers.

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution and the above resources for developers were helpful. If you have further questions, please feel free to open a new topic.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Override default address’ is closed to new replies.