Created
          November 19, 2019 23:30 
        
      - 
      
- 
        Save dexit/c04e5496c510bd7ccb16db91e8b3244c to your computer and use it in GitHub Desktop. 
    WooCommerce select first option on all single variation dropdowns
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | let selectFields = document.querySelectorAll(".wc-default-select"); | |
| selectFields.forEach( (item, index) => { | |
| let itemLen = item.length; | |
| // check length console.log(brand); | |
| if (itemLen == 2){ | |
| // set index | |
| item.selectedIndex = 1; | |
| //console.log("selected"); | |
| }else{ | |
| console.log("died"); | |
| } | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment