• Resolved 0108daniel

    (@0108daniel)


    A customer came up with the problem that he has to fill in his apartment/suite with his account.
    Here in the Netherlands this does not apply and this field should not be visible.
    My question; how can I remove the field in ‘my account’ where the customer can enter their address?

    To clarify: it is NOT about the checkout page, the field is not there.
    The field is where the customer can view their orders and edit address.
    (see screenshot) https://postimg.cc/kVjv6ymg

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support Kaushik S. a11n

    (@kaushiksomaiya)

    Hi there!

    Thank you for contacting us!

    I understand you’d like to remove the Apartment/suite fields from My Account Addresses section.

    You can add a snippet like the one below in your theme’s functions.php file:

    
    add_filter( 'woocommerce_billing_fields', 'remove_billing_account_fields', 25, 1 );
    function remove_billing_account_fields ( $billing_fields ) {
        // Only my account billing address for logged-in users
        if( is_account_page() ){
            unset($billing_fields['billing_address_1']);
            unset($billing_fields['billing_address_2']);
        }
        return $billing_fields;
    }
    

    Reference 1: https://stackoverflow.com/questions/52448313/disable-or-make-read-only-the-fields-from-edit-account-pages-in-woocommerce

    Reference 2: https://woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/

    I hope this helps! ??

    Thread Starter 0108daniel

    (@0108daniel)

    Thank you for your message.
    I use this in the snippets plugin under functions.php.
    After I click on save I get a fatal error of this code…
    Here is a screenshot https://postimg.cc/BXR2W2LP
    I asume that the code is not working.

    Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi @0108daniel

    There’s no & operator on the first line.

    Is there any code in the same functions you are trying to add this to, or did you create a new snippet? Could you send us a screenshot of what all is in the functions file? Also, are you using https://www.ads-software.com/plugins/code-snippets/ or another plugin?

    Cheers!

    Thread Starter 0108daniel

    (@0108daniel)

    I made a new snippit.
    There is no other code that have the same function.
    I use indeed the ‘code snippits’ plugin.
    Here is a screenshot of the functions file.
    https://postimg.cc/FfQQfCqb
    I disable all and tried again, but still fatal error.

    Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi @0108daniel

    I see. OK, have you by any chance added any code directly to the themes’ functions.php file that may be conflicting? If there is no such operator in the snippets functions, then it could be coming from elsewhere.

    Admittedly, I haven’t seen this before, so it would also be great if you could add your status report to your next reply. You’ll find that under “WooCommerce > Status”page.

    Cheers!

    Thread Starter 0108daniel

    (@0108daniel)

    Yes I can do that, but then the snippits plugin is useless.
    The reason I use the plugin is that it can easy turn on and off.
    When I put scripts directly in the CSS it get a mess.
    I used it to test, but there is still ‘appartment/suite’ field visable.
    The code to remove that field is not working, also when I put it in customize – extra CSS.

    Hi @0108daniel

    I understand that code is not working on your end.

    I tried to add it on my test site and it is working for me. Here’s the before and after screenshots for your reference:

    Before adding the code:

    Image Link: https://snipboard.io/VYSCT7.jpg

    Activating the code under Snippets:

    Image Link: https://snipboard.io/kVOUl7.jpg

    After the code was activated:

    Image Link: https://snipboard.io/HQypV0.jpg

    You mentioned that you created a new snippet, can you please try to disable other Snippets (if there’s any) and leave the newly added activated and see if that works?

    Just to clarify that the code works for the Billing Address. If you want to remove it under the Shipping Address, you can create a new snippet and replace the word billing by shipping.

    When I put scripts directly in the CSS it get a mess.
    I used it to test, but there is still ‘appartment/suite’ field visable.
    The code to remove that field is not working, also when I put it in customize – extra CSS.

    The code should be added via My Sites – Snippets – Add New if you have the Code Snippets plugin installed or add it to your theme’s functions.php file.

    Hope this helps!

    Thread Starter 0108daniel

    (@0108daniel)

    All other scripts are disabled, but still not working.
    The other scripts are not related to any billing adres or field so they are not conflicting.
    Is your css also working for a Astra theme?
    I tried it again and now I didn’t get the error.
    I looked in the my account page under adress and now it is working.
    Didn’t know why I get a critical error yesterday, but it’s working now.
    Thank you very much ??

    Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi @0108daniel

    That’s great news! Thanks for letting us know.

    If you have a few minutes, we’d love if you could leave us a review: https://www.ads-software.com/support/plugin/woocommerce/reviews/

    Cheers!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Adress in ‘my account’ appartment/suite required’ is closed to new replies.