added alert about changing the product type that has variations
closes #5864 @mikejolley
This commit is contained in:
parent
6b486014a9
commit
519de5be59
|
@ -1,4 +1,5 @@
|
||||||
jQuery( function($){
|
/*global woocommerce_admin_meta_boxes */
|
||||||
|
jQuery( function( $ ){
|
||||||
|
|
||||||
// Scroll to first checked category - https://github.com/scribu/wp-category-checklist-tree/blob/d1c3c1f449e1144542efa17dde84a9f52ade1739/category-checklist-tree.php
|
// Scroll to first checked category - https://github.com/scribu/wp-category-checklist-tree/blob/d1c3c1f449e1144542efa17dde84a9f52ade1739/category-checklist-tree.php
|
||||||
$(function(){
|
$(function(){
|
||||||
|
@ -85,32 +86,32 @@ jQuery( function($){
|
||||||
});
|
});
|
||||||
|
|
||||||
// PRODUCT TYPE SPECIFIC OPTIONS
|
// PRODUCT TYPE SPECIFIC OPTIONS
|
||||||
$('select#product-type').change(function(){
|
$( 'select#product-type' ).change( function () {
|
||||||
|
|
||||||
// Get value
|
// Get value
|
||||||
var select_val = $(this).val();
|
var select_val = $( this ).val();
|
||||||
|
|
||||||
if (select_val=='variable') {
|
if ( 'variable' !== select_val && 0 < $( '#variable_product_options input[name^=variable_sku]' ).length ) {
|
||||||
$('input#_manage_stock').change();
|
window.alert( woocommerce_admin_meta_boxes.i18n_product_type_alert );
|
||||||
$('input#_downloadable').prop('checked', false);
|
|
||||||
$('input#_virtual').removeAttr('checked');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (select_val=='grouped') {
|
if ( 'variable' === select_val ) {
|
||||||
$('input#_downloadable').prop('checked', false);
|
$( 'input#_manage_stock' ).change();
|
||||||
$('input#_virtual').removeAttr('checked');
|
$( 'input#_downloadable' ).prop( 'checked', false );
|
||||||
}
|
$( 'input#_virtual' ).removeAttr( 'checked' );
|
||||||
|
} else if ( 'grouped' === select_val ) {
|
||||||
else if (select_val=='external') {
|
$( 'input#_downloadable' ).prop( 'checked', false );
|
||||||
$('input#_downloadable').prop('checked', false);
|
$( 'input#_virtual' ).removeAttr( 'checked' );
|
||||||
$('input#_virtual').removeAttr('checked');
|
} else if ( 'external' === select_val ) {
|
||||||
|
$( 'input#_downloadable' ).prop( 'checked', false );
|
||||||
|
$( 'input#_virtual' ).removeAttr( 'checked' );
|
||||||
}
|
}
|
||||||
|
|
||||||
show_and_hide_panels();
|
show_and_hide_panels();
|
||||||
|
|
||||||
$('ul.wc-tabs li:visible').eq(0).find('a').click();
|
$( 'ul.wc-tabs li:visible' ).eq(0).find( 'a' ).click();
|
||||||
|
|
||||||
$('body').trigger('woocommerce-product-type-change', select_val, $(this) );
|
$( 'body' ).trigger( 'woocommerce-product-type-change', select_val, $( this ) );
|
||||||
|
|
||||||
}).change();
|
}).change();
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -214,6 +214,7 @@ class WC_Admin_Assets {
|
||||||
'i18n_download_permission_fail' => __( 'Could not grant access - the user may already have permission for this file or billing email is not set. Ensure the billing email is set, and the order has been saved.', 'woocommerce' ),
|
'i18n_download_permission_fail' => __( 'Could not grant access - the user may already have permission for this file or billing email is not set. Ensure the billing email is set, and the order has been saved.', 'woocommerce' ),
|
||||||
'i18n_permission_revoke' => __( 'Are you sure you want to revoke access to this download?', 'woocommerce' ),
|
'i18n_permission_revoke' => __( 'Are you sure you want to revoke access to this download?', 'woocommerce' ),
|
||||||
'i18n_tax_rate_already_exists' => __( 'You cannot add the same tax rate twice!', 'woocommerce' ),
|
'i18n_tax_rate_already_exists' => __( 'You cannot add the same tax rate twice!', 'woocommerce' ),
|
||||||
|
'i18n_product_type_alert' => __( 'Your product has variations! Before changing the product type can be a good idea delete the variations for avoid errors in the stock reports.', 'woocommerce' )
|
||||||
);
|
);
|
||||||
|
|
||||||
wp_localize_script( 'wc-admin-meta-boxes', 'woocommerce_admin_meta_boxes', $params );
|
wp_localize_script( 'wc-admin-meta-boxes', 'woocommerce_admin_meta_boxes', $params );
|
||||||
|
|
Loading…
Reference in New Issue