Advertisement
inovve

Auto select first available options from a variation on WooCommerce variable products

Jun 17th, 2021
1,156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.30 KB | None | 0 0
  1. add_filter('woocommerce_dropdown_variation_attribute_options_args','fun_select_default_option',10,1);
  2. function fun_select_default_option( $args)
  3. {
  4.  
  5.     if(count($args['options']) > 0) //Check the count of available options in dropdown
  6.         $args['selected'] = $args['options'][0];
  7.     return $args;
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement