Skip to content

Instantly share code, notes, and snippets.

@webdados
Created October 7, 2020 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webdados/634f5a328ecde6589c66f5eb2e4abe8d to your computer and use it in GitHub Desktop.
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
(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