wc-setup.js
2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*global wc_setup_params */
jQuery(function( $ ) {
var locale_info = $.parseJSON( wc_setup_params.locale_info );
$('select[name="store_location"]').change(function(){
var country_option = $(this).val();
var country = country_option.split( ':' )[0];
var country_locale_info = locale_info[ country ];
var hide_if_set = [ 'thousand_sep', 'decimal_sep', 'num_decimals', 'currency_pos' ];
if ( country_locale_info ) {
$.each( country_locale_info, function( index, value) {
$(':input[name="' + index + '"]').val( value ).change();
if ( -1 !== $.inArray( index, hide_if_set ) ) {
$(':input[name="' + index + '"]').closest('tr').hide();
}
} );
} else {
$(':input[name="currency_pos"]').closest('tr').show();
$(':input[name="thousand_sep"]').closest('tr').show();
$(':input[name="decimal_sep"]').closest('tr').show();
$(':input[name="num_decimals"]').closest('tr').show();
}
}).change();
$('input[name="woocommerce_calc_shipping"]').change(function(){
if ( $(this).is( ':checked' ) ) {
$(':input[name="shipping_cost_domestic"]').closest('tr').show();
$(':input[name="shipping_cost_international"]').closest('tr').show();
} else {
$(':input[name="shipping_cost_domestic"]').closest('tr').hide();
$(':input[name="shipping_cost_international"]').closest('tr').hide();
}
}).change();
$('input[name="woocommerce_calc_taxes"]').change(function(){
if ( $(this).is( ':checked' ) ) {
$(':input[name="woocommerce_prices_include_tax"], :input[name="woocommerce_import_tax_rates"]').closest('tr').show();
$('tr.tax-rates').show();
} else {
$(':input[name="woocommerce_prices_include_tax"], :input[name="woocommerce_import_tax_rates"]').closest('tr').hide();
$('tr.tax-rates').hide();
}
}).change();
$('input[name="woocommerce_import_tax_rates"]').change(function(){
if ( $(this).is( ':checked' ) ) {
$('.importing-tax-rates').show();
} else {
$('.importing-tax-rates').hide();
}
}).change();
$('.button-next').on( 'click', function() {
$('.wc-setup-content').block({
message: null,
overlayCSS: {
background: '#fff',
opacity: 0.6
}
});
return true;
});
});