Control categories export field based on export type

This commit is contained in:
Claudio Sanches 2019-08-27 16:11:05 -03:00
parent 5724b65449
commit 08e9d0bdc9
1 changed files with 15 additions and 0 deletions

View File

@ -15,6 +15,7 @@
// Events. // Events.
$form.on( 'submit', { productExportForm: this }, this.onSubmit ); $form.on( 'submit', { productExportForm: this }, this.onSubmit );
$form.find( '.woocommerce-exporter-types' ).on( 'change', { productExportForm: this }, this.exportTypeFields );
}; };
/** /**
@ -84,6 +85,20 @@
} ); } );
}; };
/**
* Handle fields per export type.
*/
productExportForm.prototype.exportTypeFields = function() {
var exportCategory = $( '.woocommerce-exporter-category' );
if ( -1 !== $.inArray( 'variation', $( this ).val() ) ) {
exportCategory.closest( 'tr' ).hide();
exportCategory.val( '' ).change(); // Reset WooSelect selected value.
} else {
exportCategory.closest( 'tr' ).show();
}
};
/** /**
* Function to call productExportForm on jquery selector. * Function to call productExportForm on jquery selector.
*/ */