diff --git a/assets/js/admin/meta-boxes-product.js b/assets/js/admin/meta-boxes-product.js index ee1665aeb4f..d2746aad4e1 100644 --- a/assets/js/admin/meta-boxes-product.js +++ b/assets/js/admin/meta-boxes-product.js @@ -91,10 +91,6 @@ jQuery( function( $ ){ // Get value var select_val = $( this ).val(); - if ( 'variable' !== select_val && 0 < $( '#variable_product_options input[name^=variable_sku]' ).length ) { - window.alert( woocommerce_admin_meta_boxes.i18n_product_type_alert ); - } - if ( 'variable' === select_val ) { $( 'input#_manage_stock' ).change(); $( 'input#_downloadable' ).prop( 'checked', false ); @@ -115,6 +111,12 @@ jQuery( function( $ ){ }).change(); + $( 'body' ).on( 'woocommerce-product-type-change', function( e, select_val ) { + if ( 'variable' !== select_val && 0 < $( '#variable_product_options input[name^=variable_sku]' ).length && $( 'body' ).triggerHandler( 'woocommerce-display-product-type-alert', select_val ) !== false ) { + window.alert( woocommerce_admin_meta_boxes.i18n_product_type_alert ); + } + }); + $('input#_downloadable, input#_virtual').change(function(){ show_and_hide_panels(); });