2015-07-10 04:32:30 +00:00
|
|
|
/*global wc_setup_params */
|
2016-04-01 10:19:55 +00:00
|
|
|
jQuery( function( $ ) {
|
2015-04-15 15:34:03 +00:00
|
|
|
|
|
|
|
var locale_info = $.parseJSON( wc_setup_params.locale_info );
|
|
|
|
|
2016-04-01 10:19:55 +00:00
|
|
|
$( 'select[name="store_location"]' ).change( function() {
|
2017-05-29 17:43:56 +00:00
|
|
|
var country_option = $(this).val().split( ':' );
|
|
|
|
var country = country_option[0];
|
|
|
|
var state = country_option[1] || false;
|
2015-04-15 15:34:03 +00:00
|
|
|
var country_locale_info = locale_info[ country ];
|
2015-04-17 13:56:34 +00:00
|
|
|
var hide_if_set = [ 'thousand_sep', 'decimal_sep', 'num_decimals', 'currency_pos' ];
|
2015-04-15 15:34:03 +00:00
|
|
|
|
|
|
|
if ( country_locale_info ) {
|
2017-05-29 17:43:56 +00:00
|
|
|
$.each( country_locale_info, function( index, value ) {
|
2015-04-17 13:56:34 +00:00
|
|
|
$(':input[name="' + index + '"]').val( value ).change();
|
|
|
|
|
2015-07-10 04:32:30 +00:00
|
|
|
if ( -1 !== $.inArray( index, hide_if_set ) ) {
|
2015-04-17 13:56:34 +00:00
|
|
|
$(':input[name="' + index + '"]').closest('tr').hide();
|
|
|
|
}
|
|
|
|
} );
|
2017-05-29 17:43:56 +00:00
|
|
|
|
|
|
|
if ( ! $.isArray( country_locale_info.tax_rates ) ) {
|
|
|
|
var tax_rates = [];
|
|
|
|
|
|
|
|
if ( state && country_locale_info.tax_rates[ state ] ) {
|
|
|
|
tax_rates = tax_rates.concat( country_locale_info.tax_rates[ state ] );
|
|
|
|
} else if ( country_locale_info.tax_rates[ '' ] ) {
|
|
|
|
tax_rates = tax_rates.concat( country_locale_info.tax_rates[ '' ] );
|
|
|
|
}
|
|
|
|
|
|
|
|
tax_rates = tax_rates.concat( country_locale_info.tax_rates[ '*' ] || [] );
|
|
|
|
|
|
|
|
if ( tax_rates.length ) {
|
|
|
|
var $rate_table = $( 'table.tax-rates tbody' ).empty();
|
|
|
|
|
|
|
|
$.each( tax_rates, function( index, rate ) {
|
|
|
|
$( '<tr>', {
|
|
|
|
html: [
|
2017-05-29 18:50:36 +00:00
|
|
|
$( '<td>', { 'class': 'readonly', text: rate.country || '' } ),
|
|
|
|
$( '<td>', { 'class': 'readonly', text: rate.state || '*' } ),
|
|
|
|
$( '<td>', { 'class': 'readonly', text: rate.rate || '' } ),
|
|
|
|
$( '<td>', { 'class': 'readonly', text: rate.name || '' } )
|
2017-05-29 17:43:56 +00:00
|
|
|
]
|
|
|
|
} ).appendTo( $rate_table );
|
|
|
|
} );
|
|
|
|
|
|
|
|
$( '.tax-rates' ).show();
|
|
|
|
} else {
|
|
|
|
$( '.tax-rates' ).hide();
|
|
|
|
}
|
|
|
|
}
|
2015-04-15 15:34:03 +00:00
|
|
|
} else {
|
2015-04-29 13:55:12 +00:00
|
|
|
$(':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();
|
2017-05-29 17:43:56 +00:00
|
|
|
$( '.tax-rates' ).hide();
|
2015-04-15 15:34:03 +00:00
|
|
|
}
|
2016-04-01 10:19:55 +00:00
|
|
|
} ).change();
|
2015-04-15 15:34:03 +00:00
|
|
|
|
2016-04-01 10:19:55 +00:00
|
|
|
$( 'input[name="woocommerce_calc_taxes"]' ).change( function() {
|
2015-04-22 14:30:50 +00:00
|
|
|
if ( $(this).is( ':checked' ) ) {
|
2015-04-27 15:33:52 +00:00
|
|
|
$(':input[name="woocommerce_prices_include_tax"], :input[name="woocommerce_import_tax_rates"]').closest('tr').show();
|
2015-04-22 14:30:50 +00:00
|
|
|
$('tr.tax-rates').show();
|
|
|
|
} else {
|
2015-04-27 15:33:52 +00:00
|
|
|
$(':input[name="woocommerce_prices_include_tax"], :input[name="woocommerce_import_tax_rates"]').closest('tr').hide();
|
2015-04-22 14:30:50 +00:00
|
|
|
$('tr.tax-rates').hide();
|
|
|
|
}
|
2016-04-01 10:19:55 +00:00
|
|
|
} ).change();
|
2015-04-22 14:30:50 +00:00
|
|
|
|
2016-03-31 16:17:11 +00:00
|
|
|
$( '.button-next' ).on( 'click', function() {
|
2015-08-21 18:12:36 +00:00
|
|
|
$('.wc-setup-content').block({
|
|
|
|
message: null,
|
|
|
|
overlayCSS: {
|
|
|
|
background: '#fff',
|
|
|
|
opacity: 0.6
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return true;
|
2016-04-01 10:19:55 +00:00
|
|
|
} );
|
2015-08-21 18:12:36 +00:00
|
|
|
|
2017-05-31 11:00:10 +00:00
|
|
|
$( '.wc-wizard-payment-gateways, .wc-wizard-shipping-methods' ).on( 'change', '.wc-wizard-gateway-enable input, .wc-wizard-shipping-enable input', function() {
|
2016-04-01 16:30:04 +00:00
|
|
|
if ( $( this ).is( ':checked' ) ) {
|
|
|
|
$( this ).closest( 'li' ).addClass( 'checked' );
|
|
|
|
} else {
|
|
|
|
$( this ).closest( 'li' ).removeClass( 'checked' );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2017-05-31 11:00:10 +00:00
|
|
|
$( '.wc-wizard-payment-gateways, .wc-wizard-shipping-methods' ).on( 'click', 'li.wc-wizard-gateway, li.wc-wizard-shipping', function() {
|
|
|
|
var $enabled = $( this ).find( '.wc-wizard-gateway-enable input, .wc-wizard-shipping-enable input' );
|
2016-04-01 16:30:04 +00:00
|
|
|
|
|
|
|
$enabled.prop( 'checked', ! $enabled.prop( 'checked' ) ).change();
|
|
|
|
} );
|
|
|
|
|
2017-05-31 11:00:10 +00:00
|
|
|
$( '.wc-wizard-payment-gateways li, .wc-wizard-shipping-methods li' ).on( 'click', 'table, a', function( e ) {
|
2016-04-01 16:30:04 +00:00
|
|
|
e.stopPropagation();
|
|
|
|
} );
|
2016-04-01 10:19:55 +00:00
|
|
|
} );
|