Skip to content

Commit

Permalink
remove, don't hide, variation attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Feb 1, 2013
1 parent bccd92d commit bbc8cea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions assets/js/frontend/add-to-cart-variation.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,17 @@ jQuery(document).ready(function($) {
$variation_form = $(this).closest('form.variations_form');

// Loop through selects and disable/enable options based on selections
$variation_form.find('.variations select').each(function( index, el ){
$variation_form.find('.variations select').each(function( index, el ) {

current_attr_select = $(el);

// Disable all
current_attr_select.find('option:gt(0)').attr('disabled', 'disabled');
// Reset options
if ( ! current_attr_select.data( 'attribute_options' ) )
current_attr_select.data( 'attribute_options', current_attr_select.find('option:gt(0)').get() )

current_attr_select.find('option:gt(0)').remove();
current_attr_select.append( current_attr_select.data( 'attribute_options' ) );
current_attr_select.find('option:gt(0)').removeClass('active');

// Get name
var current_attr_name = current_attr_select.attr('name');
Expand All @@ -213,10 +218,12 @@ jQuery(document).ready(function($) {
attr_val = attr_val.replace(/"/g, "\\\"");

// Compare the meercat
current_attr_select.find('option[value="' + attr_val + '"]').removeAttr('disabled');
current_attr_select.find('option[value="' + attr_val + '"]').addClass('active');

} else {
current_attr_select.find('option').removeAttr('disabled');

current_attr_select.find('option:gt(0)').addClass('active');

}

}
Expand All @@ -225,6 +232,9 @@ jQuery(document).ready(function($) {

}

// Detach inactive
current_attr_select.find('option:gt(0):not(.active)').remove();

});

// Custom event for when variations have been updated
Expand Down
2 changes: 1 addition & 1 deletion assets/js/frontend/add-to-cart-variation.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bbc8cea

Please sign in to comment.