Retool the export to use the global object, not parsing out of the dom.
This commit is contained in:
parent
521d8f4861
commit
9946bd1c5c
|
@ -108,35 +108,28 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the exporting of tax rates.
|
* Handle the exporting of tax rates, and build it off the global `data.rates` object.
|
||||||
*
|
*
|
||||||
* As an aside: Why is this being handled in Javascript instead of being built by php? -George
|
* @todo: Have the `export` button save the current form and generate this from php, so there's no chance the current page is out of date.
|
||||||
*/
|
*/
|
||||||
$('.wc_tax_rates .export').click(function() {
|
$('.wc_tax_rates .export').click(function() {
|
||||||
var csv_data = 'data:application/csv;charset=utf-8,' + data.strings.csv_data_cols.join(',') + '\n';
|
var csv_data = 'data:application/csv;charset=utf-8,' + data.strings.csv_data_cols.join(',') + '\n';
|
||||||
|
|
||||||
$('#rates tr:visible').each(function() {
|
$.each( data.rates, function( id, rowData ) {
|
||||||
var row = '';
|
var row = '';
|
||||||
$(this).find('td:not(.sort) input').each(function() {
|
|
||||||
var val = '';
|
|
||||||
|
|
||||||
if ( $(this).is('.checkbox') ) {
|
row += rowData.tax_rate_country + ',';
|
||||||
if ( $(this).is(':checked') ) {
|
row += rowData.tax_rate_state + ',';
|
||||||
val = 1;
|
row += rowData.tax_rate_postcode ? rowData.tax_rate_postcode.join( '; ' ) : '' + ',';
|
||||||
} else {
|
row += rowData.tax_rate_city ? rowData.tax_rate_city.join( '; ' ) : '' + ',';
|
||||||
val = 0;
|
row += rowData.tax_rate + ',';
|
||||||
}
|
row += rowData.tax_rate_name + ',';
|
||||||
} else {
|
row += rowData.tax_rate_priority + ',';
|
||||||
val = $(this).val();
|
row += rowData.tax_rate_compound + ',';
|
||||||
if ( ! val ) {
|
row += rowData.tax_rate_shipping + ',';
|
||||||
val = $( this ).attr( 'placeholder' );
|
row += data.current_class;
|
||||||
}
|
|
||||||
}
|
csv_data += row + '\n';
|
||||||
row = row + val + ',';
|
|
||||||
});
|
|
||||||
row = row + data.current_class;
|
|
||||||
//row.substring( 0, row.length - 1 );
|
|
||||||
csv_data = csv_data + row + '\n';
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(this).attr( 'href', encodeURI( csv_data ) );
|
$(this).attr( 'href', encodeURI( csv_data ) );
|
||||||
|
|
Loading…
Reference in New Issue