1 /*global wc_setup_params */
2 jQuery( function( $ ) {
4 var locale_info = $.parseJSON( wc_setup_params.locale_info );
6 $( 'select[name="store_location"]' ).change( function() {
7 var country_option = $(this).val().split( ':' );
8 var country = country_option[0];
9 var state = country_option[1] || false;
10 var country_locale_info = locale_info[ country ];
11 var hide_if_set = [ 'thousand_sep', 'decimal_sep', 'num_decimals', 'currency_pos' ];
13 if ( country_locale_info ) {
14 $.each( country_locale_info, function( index, value ) {
15 $(':input[name="' + index + '"]').val( value ).change();
17 if ( -1 !== $.inArray( index, hide_if_set ) ) {
18 $(':input[name="' + index + '"]').closest('tr').hide();
22 if ( ! $.isArray( country_locale_info.tax_rates ) ) {
25 if ( state && country_locale_info.tax_rates[ state ] ) {
26 tax_rates = tax_rates.concat( country_locale_info.tax_rates[ state ] );
27 } else if ( country_locale_info.tax_rates[ '' ] ) {
28 tax_rates = tax_rates.concat( country_locale_info.tax_rates[ '' ] );
31 tax_rates = tax_rates.concat( country_locale_info.tax_rates[ '*' ] || [] );
33 if ( tax_rates.length ) {
34 var $rate_table = $( 'table.tax-rates tbody' ).empty();
36 $.each( tax_rates, function( index, rate ) {
39 $( '<td>', { 'class': 'readonly', text: rate.country || '' } ),
40 $( '<td>', { 'class': 'readonly', text: rate.state || '*' } ),
41 $( '<td>', { 'class': 'readonly', text: rate.rate || '' } ),
42 $( '<td>', { 'class': 'readonly', text: rate.name || '' } )
44 } ).appendTo( $rate_table );
47 $( '.tax-rates' ).show();
49 $( '.tax-rates' ).hide();
53 $(':input[name="currency_pos"]').closest('tr').show();
54 $(':input[name="thousand_sep"]').closest('tr').show();
55 $(':input[name="decimal_sep"]').closest('tr').show();
56 $(':input[name="num_decimals"]').closest('tr').show();
57 $( '.tax-rates' ).hide();
61 $( 'input[name="woocommerce_calc_taxes"]' ).change( function() {
62 if ( $(this).is( ':checked' ) ) {
63 $(':input[name="woocommerce_prices_include_tax"], :input[name="woocommerce_import_tax_rates"]').closest('tr').show();
64 $('tr.tax-rates').show();
66 $(':input[name="woocommerce_prices_include_tax"], :input[name="woocommerce_import_tax_rates"]').closest('tr').hide();
67 $('tr.tax-rates').hide();
71 $( '.button-next' ).on( 'click', function() {
72 $('.wc-setup-content').block({
82 $( '.wc-wizard-payment-gateways, .wc-wizard-shipping-methods' ).on( 'change', '.wc-wizard-gateway-enable input, .wc-wizard-shipping-enable input', function() {
83 if ( $( this ).is( ':checked' ) ) {
84 $( this ).closest( 'li' ).addClass( 'checked' );
86 $( this ).closest( 'li' ).removeClass( 'checked' );
90 $( '.wc-wizard-payment-gateways, .wc-wizard-shipping-methods' ).on( 'click', 'li.wc-wizard-gateway, li.wc-wizard-shipping', function() {
91 var $enabled = $( this ).find( '.wc-wizard-gateway-enable input, .wc-wizard-shipping-enable input' );
93 $enabled.prop( 'checked', ! $enabled.prop( 'checked' ) ).change();
96 $( '.wc-wizard-payment-gateways li, .wc-wizard-shipping-methods li' ).on( 'click', 'table, a', function( e ) {