Add empty option in “Choose your sales agent” dropdown
Sunday, 07 March 2021
WooCommerce B2B Sales Agents has the “Default sales agent” option which allows you to choose a default sales agent to be automatically assigned to all customers who register.
You can set this option to “Allow to choose”, which allows the customer to choose their referral agent during checkout from those available.
If you want to insert an empty option in this drop-down menu, either as a header or as a label, edit functions.php file that you find in your site’s FTP space in:
wp-content/themes/{YOUR_ACTIVE_THEME}/functions.php
and insert this code:
add_filter( 'woocommerce_form_field_args', function( $args, $key, $value ) { if ( 'wcb2bsa_sales_agent' == $key ) { $args['options'] = array_merge( array( '' => __( 'Choose your sales agent', 'woocommerce-b2b-sales-agents') ), $args['options'] ); } return $args; }, 10, 3 );
It is advisable not to edit the theme files directly, but to use a child theme.
For more information on child themes, please read: WordPress Official guide on Child Themes