How would I go about changing this PHP code to to change Choose an option based on the id of the select element in the Woocommerce plugin for WordPress? I believe I have found t
If you are wondering how to replace “Choose an option” with corresponding attribute/variation name, then here’s how you can do that. edit variable.php and lookout for the code as the one shown below
Open the variable.php(wp-content/plugins/woocommerce/includes/variable.php) file to your woocommerce and change this (from line 41 to 43): (Remove this 3 line code)
$selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( urldecode( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ) : $product->get_variation_default_attribute( $attribute_name );
wc_dropdown_variation_attribute_options( array( 'options' => $options, 'attribute' => $attribute_name, 'product' => $product, 'selected' => $selected ) );
echo end( $attribute_keys ) === $attribute_name ? apply_filters( 'woocommerce_reset_variations_link', '' . __( 'Clear', 'woocommerce' ) . '' ) : '';
Then add this code
wc_dropdown_variation_attribute_options
array( 'options' => $options,
'attribute' => $attribute_name,
'product' => $product,
'selected' => $selected,
'show_option_none'=> wc_attribute_label( $attribute_name )
) );
It's working all WordPress version Thanks