• Resolved boomkaboomka

    (@boomkaboomka)


    Hello,

    just curious if there is a possibility to add one empty item to the dropdown of the billing title field and set it to be the default?
    I would like to have it truly optional and out of the box it defaults to Mr, so I cannot know if it was a female and she skipped the selection or because it was indeed a male.

    Thanks and best regards!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author vendidero

    (@vendidero)

    Hi there,

    you would need to add a default option via a filter:
    https://gist.github.com/vendidero/de80a66342893a929d20ee90be70bea3

    And mark the field as required to make sure the customer provides a valid value by using the woocommerce_billing_fields filter.

    Cheers

    Thread Starter boomkaboomka

    (@boomkaboomka)

    Hi there,

    thank you for your quick reply!
    It took me a while to realize what needs to be altered to achieve the result I was after, but now it works like a charm.

    Thanks a lot!

    P.S. In case someone else wants to achieve the same result, this is how my code looks like:

    function my_child_add_new_title( $titles ) {
        $titles[1] = '-';
        $titles[2] = __( 'Ms.', 'woocommerce-germanized' );
        $titles[3] = __( 'Mr.', 'woocommerce-germanized' );
        return $titles;
    }
    add_filter( 'woocommerce_gzd_title_options', 'my_child_add_new_title', 10, 1 );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to add empty item as default for billing title field’ is closed to new replies.