Created
December 20, 2022 09:50
-
-
Save elias1435/e2e0971613b9b3ec00a2a3d0015ab4ca to your computer and use it in GitHub Desktop.
Change ‘Choose an Option’ variation dropdown label in WooCommerce. Code goes in function.php file of your active child theme (or active theme).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* OR you can use singular_name instead of name like: */ | |
add_filter( 'woocommerce_dropdown_variation_attribute_options_args', 'filter_dropdown_variation_args', 10 ); | |
function filter_dropdown_variation_args( $args ) { | |
$args['show_option_none'] = apply_filters( 'the_title', get_taxonomy( $args['attribute'] )->labels->singular_name ); | |
return $args; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* You can use wc_attribute_label() dedicated function to get the product attribute label name. */ | |
add_filter( 'woocommerce_dropdown_variation_attribute_options_args', 'filter_dropdown_variation_args', 10 ); | |
function filter_dropdown_variation_args( $args ) { | |
$args['show_option_none'] = apply_filters( 'the_title', wc_attribute_label( $args['attribute'] ) ); | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment