Created
May 9, 2022 14:15
-
-
Save Preciousomonze/f50d497c352e15e8730808eddd79c56a to your computer and use it in GitHub Desktop.
Pre-select WooCommerce first variation option. Copy code and put in your child theme's function.php or anywhere you see fit. Use at your risk, enjoy! I mean, what's life without taking risks? ๐
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
<?php | |
/** | |
* Pre-selects first variation option. | |
* | |
* @param array $args | |
* return array | |
*/ | |
function pekky_wc_select_first_variation_option( $args ) { | |
$args['selected'] = $args['options'][0]; | |
return $args; | |
} | |
add_filter( 'woocommerce_dropdown_variation_attribute_options_args', 'filter_dropdown_variation_args', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment