Created
October 7, 2020 15:33
-
-
Save webdados/634f5a328ecde6589c66f5eb2e4abe8d to your computer and use it in GitHub Desktop.
Show all options on the first select for a WooCommerce variable products even if not available
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
(function($) { | |
$( '.variations_form' ).on( 'woocommerce_variation_has_changed', function( ev ) { | |
$( this ).find( '.variations select' ).each( function( index, el ) { | |
//Get the first select current value | |
var value = $( el ).val(); | |
//Get the original HTML from .data( 'attribute_html' ) and replace it again on the element. | |
$( el ).html( $( el ).data( 'attribute_html' ) ); | |
//Then set the value again | |
$( el ).val( value ); | |
return false; //Only the first one | |
}); | |
} ); | |
})( jQuery ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment