From ece4b83562747039a1e639bfcfe126d405d4994b Mon Sep 17 00:00:00 2001 From: thenbrent Date: Wed, 20 Aug 2014 15:46:30 -0700 Subject: [PATCH] Allow extensions to hijack i18n_product_type_alert --- assets/js/admin/meta-boxes-product.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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(); });