Disable already added attributes #6189

This commit is contained in:
Mike Jolley 2014-11-26 11:35:07 +00:00
parent 06129f60cd
commit 3904035003
3 changed files with 11 additions and 3 deletions

View File

@ -271,6 +271,12 @@ jQuery( function( $ ){
});
};
$('.product_attributes .woocommerce_attribute').each(function(index, el){
if ( $(el).css('display') != 'none' && $(el).is('.taxonomy') ) {
$('select.attribute_taxonomy').find('option[value="' + $(el).data( 'taxonomy' ) + '"]').attr('disabled','disabled');
}
});
// Add rows
$('button.add_attribute').on('click', function(){
@ -278,7 +284,7 @@ jQuery( function( $ ){
var attribute_type = $('select.attribute_taxonomy').val();
if (!attribute_type) {
if ( ! attribute_type ) {
var product_type = $('select#product-type').val();
if (product_type!='variable') enable_variation = 'style="display:none;"'; else enable_variation = '';
@ -327,6 +333,7 @@ jQuery( function( $ ){
$('.product_attributes').append( $(thisrow) );
$(thisrow).show().find('.woocommerce_attribute_data').show();
attribute_row_indexes();
$('select.attribute_taxonomy').find('option[value="' + attribute_type + '"]').attr('disabled','disabled');
}
@ -357,6 +364,7 @@ jQuery( function( $ ){
if ($parent.is('.taxonomy')) {
$parent.find('select, input[type=text]').val('');
$parent.hide();
$('select.attribute_taxonomy').find('option[value="' + $parent.data( 'taxonomy' ) + '"]').removeAttr('disabled');
} else {
$parent.find('select, input[type=text]').val('');
$parent.hide();

File diff suppressed because one or more lines are too long

View File

@ -445,7 +445,7 @@ class WC_Meta_Box_Product_Data {
// Any set?
$has_terms = ( is_wp_error( $post_terms ) || ! $post_terms || sizeof( $post_terms ) == 0 ) ? 0 : 1;
?>
<div class="woocommerce_attribute wc-metabox closed taxonomy <?php echo $attribute_taxonomy_name; ?>" rel="<?php echo $position; ?>" <?php if ( ! $has_terms ) echo 'style="display:none"'; ?>>
<div data-taxonomy="<?php echo esc_attr( $attribute_taxonomy_name ); ?>" class="woocommerce_attribute wc-metabox closed taxonomy <?php echo esc_attr( $attribute_taxonomy_name ); ?>" rel="<?php echo $position; ?>" <?php if ( ! $has_terms ) echo 'style="display:none"'; ?>>
<h3>
<button type="button" class="remove_row button"><?php _e( 'Remove', 'woocommerce' ); ?></button>
<div class="handlediv" title="<?php _e( 'Click to toggle', 'woocommerce' ); ?>"></div>