Skip to content

Instantly share code, notes, and snippets.

@akther80
Created October 27, 2023 13:19
Show Gist options
  • Save akther80/af0a62b755c41bb866caee596815c1d2 to your computer and use it in GitHub Desktop.
Save akther80/af0a62b755c41bb866caee596815c1d2 to your computer and use it in GitHub Desktop.
MyTravel - Rename filter dropdown option name
$instance = MAS_Travels::instance();
remove_filter( 'woocommerce_dropdown_variation_attribute_options_html', array( $instance, 'mas_travels_filter_dropdown_option_html' ), 12, 2 );
add_filter( 'woocommerce_dropdown_variation_attribute_options_html','mas_travels_filter_dropdown_option_html',12, 2 );
function mas_travels_filter_dropdown_option_html( $html, $args ) {
global $product;
$product_format = get_product_format() ? get_product_format() : 'standard';
$product_type = $product->get_type();
if ( 'tour' === $product_format || 'activity' === $product_format ) :
$show_option_none_text = $args['show_option_none'] ? $args['show_option_none'] : esc_html__( 'Select', 'mas-travels' );
$show_option_none_html = '<option value="">' . esc_html( $show_option_none_text ) . '</option>';
$html = str_replace( $show_option_none_html, '<option value="">' . esc_html( 'Select' ) . '</option>', $html );
endif;
return $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment