Calc totals. Closes #883.

This commit is contained in:
Mike Jolley 2012-09-18 19:07:13 +01:00
parent 8625d74c90
commit aaeb0ec0fb
8 changed files with 543 additions and 28 deletions

View File

@ -410,7 +410,7 @@ function woocommerce_order_items_meta_box($post) {
</td>
<td class="quantity" width="1%">
<input type="text" name="item_quantity[<?php echo $loop; ?>]" placeholder="0" value="<?php echo esc_attr( $item['qty'] ); ?>" size="2" class="quantity" />
<input type="number" step="any" min="0" autocomplete="off" name="item_quantity[<?php echo $loop; ?>]" placeholder="0" value="<?php echo esc_attr( $item['qty'] ); ?>" size="4" class="quantity" />
</td>
<td class="line_subtotal" width="1%">

File diff suppressed because one or more lines are too long

View File

@ -739,7 +739,7 @@ table.wc_status_table {
text-align: center;
input {
text-align: center;
width: 40px;
width: 50px;
}
}
td.tax_class, th.tax_class {

View File

@ -0,0 +1,412 @@
/*!
* accounting.js v0.3.2
* Copyright 2011, Joss Crowcroft
*
* Freely distributable under the MIT license.
* Portions of accounting.js are inspired or borrowed from underscore.js
*
* Full details and documentation:
* http://josscrowcroft.github.com/accounting.js/
*/
(function(root, undefined) {
/* --- Setup --- */
// Create the local library object, to be exported or referenced globally later
var lib = {};
// Current version
lib.version = '0.3.2';
/* --- Exposed settings --- */
// The library's settings configuration object. Contains default parameters for
// currency and number formatting
lib.settings = {
currency: {
symbol : "$", // default currency symbol is '$'
format : "%s%v", // controls output: %s = symbol, %v = value (can be object, see docs)
decimal : ".", // decimal point separator
thousand : ",", // thousands separator
precision : 2, // decimal places
grouping : 3 // digit grouping (not implemented yet)
},
number: {
precision : 0, // default precision on numbers is 0
grouping : 3, // digit grouping (not implemented yet)
thousand : ",",
decimal : "."
}
};
/* --- Internal Helper Methods --- */
// Store reference to possibly-available ECMAScript 5 methods for later
var nativeMap = Array.prototype.map,
nativeIsArray = Array.isArray,
toString = Object.prototype.toString;
/**
* Tests whether supplied parameter is a string
* from underscore.js
*/
function isString(obj) {
return !!(obj === '' || (obj && obj.charCodeAt && obj.substr));
}
/**
* Tests whether supplied parameter is a string
* from underscore.js, delegates to ECMA5's native Array.isArray
*/
function isArray(obj) {
return nativeIsArray ? nativeIsArray(obj) : toString.call(obj) === '[object Array]';
}
/**
* Tests whether supplied parameter is a true object
*/
function isObject(obj) {
return obj && toString.call(obj) === '[object Object]';
}
/**
* Extends an object with a defaults object, similar to underscore's _.defaults
*
* Used for abstracting parameter handling from API methods
*/
function defaults(object, defs) {
var key;
object = object || {};
defs = defs || {};
// Iterate over object non-prototype properties:
for (key in defs) {
if (defs.hasOwnProperty(key)) {
// Replace values with defaults only if undefined (allow empty/zero values):
if (object[key] == null) object[key] = defs[key];
}
}
return object;
}
/**
* Implementation of `Array.map()` for iteration loops
*
* Returns a new Array as a result of calling `iterator` on each array value.
* Defers to native Array.map if available
*/
function map(obj, iterator, context) {
var results = [], i, j;
if (!obj) return results;
// Use native .map method if it exists:
if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
// Fallback for native .map:
for (i = 0, j = obj.length; i < j; i++ ) {
results[i] = iterator.call(context, obj[i], i, obj);
}
return results;
}
/**
* Check and normalise the value of precision (must be positive integer)
*/
function checkPrecision(val, base) {
val = Math.round(Math.abs(val));
return isNaN(val)? base : val;
}
/**
* Parses a format string or object and returns format obj for use in rendering
*
* `format` is either a string with the default (positive) format, or object
* containing `pos` (required), `neg` and `zero` values (or a function returning
* either a string or object)
*
* Either string or format.pos must contain "%v" (value) to be valid
*/
function checkCurrencyFormat(format) {
var defaults = lib.settings.currency.format;
// Allow function as format parameter (should return string or object):
if ( typeof format === "function" ) format = format();
// Format can be a string, in which case `value` ("%v") must be present:
if ( isString( format ) && format.match("%v") ) {
// Create and return positive, negative and zero formats:
return {
pos : format,
neg : format.replace("-", "").replace("%v", "-%v"),
zero : format
};
// If no format, or object is missing valid positive value, use defaults:
} else if ( !format || !format.pos || !format.pos.match("%v") ) {
// If defaults is a string, casts it to an object for faster checking next time:
return ( !isString( defaults ) ) ? defaults : lib.settings.currency.format = {
pos : defaults,
neg : defaults.replace("%v", "-%v"),
zero : defaults
};
}
// Otherwise, assume format was fine:
return format;
}
/* --- API Methods --- */
/**
* Takes a string/array of strings, removes all formatting/cruft and returns the raw float value
* alias: accounting.`parse(string)`
*
* Decimal must be included in the regular expression to match floats (defaults to
* accounting.settings.number.decimal), so if the number uses a non-standard decimal
* separator, provide it as the second argument.
*
* Also matches bracketed negatives (eg. "$ (1.99)" => -1.99)
*
* Doesn't throw any errors (`NaN`s become 0) but this may change in future
*/
var unformat = lib.unformat = lib.parse = function(value, decimal) {
// Recursively unformat arrays:
if (isArray(value)) {
return map(value, function(val) {
return unformat(val, decimal);
});
}
// Fails silently (need decent errors):
value = value || 0;
// Return the value as-is if it's already a number:
if (typeof value === "number") return value;
// Default decimal point comes from settings, but could be set to eg. "," in opts:
decimal = decimal || lib.settings.number.decimal;
// Build regex to strip out everything except digits, decimal point and minus sign:
var regex = new RegExp("[^0-9-" + decimal + "]", ["g"]),
unformatted = parseFloat(
("" + value)
.replace(/\((.*)\)/, "-$1") // replace bracketed values with negatives
.replace(regex, '') // strip out any cruft
.replace(decimal, '.') // make sure decimal point is standard
);
// This will fail silently which may cause trouble, let's wait and see:
return !isNaN(unformatted) ? unformatted : 0;
};
/**
* Implementation of toFixed() that treats floats more like decimals
*
* Fixes binary rounding issues (eg. (0.615).toFixed(2) === "0.61") that present
* problems for accounting- and finance-related software.
*/
var toFixed = lib.toFixed = function(value, precision) {
precision = checkPrecision(precision, lib.settings.number.precision);
var power = Math.pow(10, precision);
// Multiply up by precision, round accurately, then divide and use native toFixed():
return (Math.round(lib.unformat(value) * power) / power).toFixed(precision);
};
/**
* Format a number, with comma-separated thousands and custom precision/decimal places
*
* Localise by overriding the precision and thousand / decimal separators
* 2nd parameter `precision` can be an object matching `settings.number`
*/
var formatNumber = lib.formatNumber = function(number, precision, thousand, decimal) {
// Resursively format arrays:
if (isArray(number)) {
return map(number, function(val) {
return formatNumber(val, precision, thousand, decimal);
});
}
// Clean up number:
number = unformat(number);
// Build options object from second param (if object) or all params, extending defaults:
var opts = defaults(
(isObject(precision) ? precision : {
precision : precision,
thousand : thousand,
decimal : decimal
}),
lib.settings.number
),
// Clean up precision
usePrecision = checkPrecision(opts.precision),
// Do some calc:
negative = number < 0 ? "-" : "",
base = parseInt(toFixed(Math.abs(number || 0), usePrecision), 10) + "",
mod = base.length > 3 ? base.length % 3 : 0;
// Format the number:
return negative + (mod ? base.substr(0, mod) + opts.thousand : "") + base.substr(mod).replace(/(\d{3})(?=\d)/g, "$1" + opts.thousand) + (usePrecision ? opts.decimal + toFixed(Math.abs(number), usePrecision).split('.')[1] : "");
};
/**
* Format a number into currency
*
* Usage: accounting.formatMoney(number, symbol, precision, thousandsSep, decimalSep, format)
* defaults: (0, "$", 2, ",", ".", "%s%v")
*
* Localise by overriding the symbol, precision, thousand / decimal separators and format
* Second param can be an object matching `settings.currency` which is the easiest way.
*
* To do: tidy up the parameters
*/
var formatMoney = lib.formatMoney = function(number, symbol, precision, thousand, decimal, format) {
// Resursively format arrays:
if (isArray(number)) {
return map(number, function(val){
return formatMoney(val, symbol, precision, thousand, decimal, format);
});
}
// Clean up number:
number = unformat(number);
// Build options object from second param (if object) or all params, extending defaults:
var opts = defaults(
(isObject(symbol) ? symbol : {
symbol : symbol,
precision : precision,
thousand : thousand,
decimal : decimal,
format : format
}),
lib.settings.currency
),
// Check format (returns object with pos, neg and zero):
formats = checkCurrencyFormat(opts.format),
// Choose which format to use for this value:
useFormat = number > 0 ? formats.pos : number < 0 ? formats.neg : formats.zero;
// Return with currency symbol added:
return useFormat.replace('%s', opts.symbol).replace('%v', formatNumber(Math.abs(number), checkPrecision(opts.precision), opts.thousand, opts.decimal));
};
/**
* Format a list of numbers into an accounting column, padding with whitespace
* to line up currency symbols, thousand separators and decimals places
*
* List should be an array of numbers
* Second parameter can be an object containing keys that match the params
*
* Returns array of accouting-formatted number strings of same length
*
* NB: `white-space:pre` CSS rule is required on the list container to prevent
* browsers from collapsing the whitespace in the output strings.
*/
lib.formatColumn = function(list, symbol, precision, thousand, decimal, format) {
if (!list) return [];
// Build options object from second param (if object) or all params, extending defaults:
var opts = defaults(
(isObject(symbol) ? symbol : {
symbol : symbol,
precision : precision,
thousand : thousand,
decimal : decimal,
format : format
}),
lib.settings.currency
),
// Check format (returns object with pos, neg and zero), only need pos for now:
formats = checkCurrencyFormat(opts.format),
// Whether to pad at start of string or after currency symbol:
padAfterSymbol = formats.pos.indexOf("%s") < formats.pos.indexOf("%v") ? true : false,
// Store value for the length of the longest string in the column:
maxLength = 0,
// Format the list according to options, store the length of the longest string:
formatted = map(list, function(val, i) {
if (isArray(val)) {
// Recursively format columns if list is a multi-dimensional array:
return lib.formatColumn(val, opts);
} else {
// Clean up the value
val = unformat(val);
// Choose which format to use for this value (pos, neg or zero):
var useFormat = val > 0 ? formats.pos : val < 0 ? formats.neg : formats.zero,
// Format this value, push into formatted list and save the length:
fVal = useFormat.replace('%s', opts.symbol).replace('%v', formatNumber(Math.abs(val), checkPrecision(opts.precision), opts.thousand, opts.decimal));
if (fVal.length > maxLength) maxLength = fVal.length;
return fVal;
}
});
// Pad each number in the list and send back the column of numbers:
return map(formatted, function(val, i) {
// Only if this is a string (not a nested array, which would have already been padded):
if (isString(val) && val.length < maxLength) {
// Depending on symbol position, pad after symbol or at index 0:
return padAfterSymbol ? val.replace(opts.symbol, opts.symbol+(new Array(maxLength - val.length + 1).join(" "))) : (new Array(maxLength - val.length + 1).join(" ")) + val;
}
return val;
});
};
/* --- Module Definition --- */
// Export accounting for CommonJS. If being loaded as an AMD module, define it as such.
// Otherwise, just add `accounting` to the global object
if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = lib;
}
exports.accounting = lib;
} else if (typeof define === 'function' && define.amd) {
// Return the library as an AMD module:
define([], function() {
return lib;
});
} else {
// Use accounting.noConflict to restore `accounting` back to its original value.
// Returns a reference to the library's `accounting` object;
// e.g. `var numbers = accounting.noConflict();`
lib.noConflict = (function(oldAccounting) {
return function() {
// Reset the value of the root's `accounting` variable:
root.accounting = oldAccounting;
// Delete the noConflict method:
lib.noConflict = undefined;
// Return reference to the library to re-assign it:
return lib;
};
})(root.accounting);
// Declare `fx` on the root (global/window) object:
root['accounting'] = lib;
}
// Root will be `window` in browser or `global` on the server:
}(this));

View File

@ -151,7 +151,102 @@ jQuery( function($){
}
return false;
});
$('#order_items_list').on( 'init_row', 'tr.item', function() {
var $row = $(this);
var $qty = $row.find('input.quantity');
var qty = $qty.val();
var line_subtotal = $row.find('input.line_subtotal').val();
var line_total = $row.find('input.line_total').val();
var line_tax = $row.find('input.line_tax').val();
var line_subtotal_tax = $row.find('input.line_subtotal_tax').val();
if ( qty ) {
unit_subtotal = accounting.toFixed( ( line_subtotal / qty ), 2 );
unit_subtotal_tax = accounting.toFixed( ( line_subtotal_tax / qty ), 2 );
unit_total = accounting.toFixed( ( line_total / qty ), 2 );
unit_total_tax = accounting.toFixed( ( line_tax / qty ), 2 );
} else {
unit_subtotal = unit_subtotal_tax = unit_total = unit_total_tax = 0;
}
$qty.attr( 'data-o_qty', qty );
$row.attr( 'data-unit_subtotal', unit_subtotal );
$row.attr( 'data-unit_subtotal_tax', unit_subtotal_tax );
$row.attr( 'data-unit_total', unit_total );
$row.attr( 'data-unit_total_tax', unit_total_tax );
});
// When the page is loaded, store the unit costs
$('#order_items_list tr.item').each( function() {
$(this).trigger('init_row');
} );
// When the qty is changed, increase or decrease costs
$('#order_items_list').on( 'change', 'input.quantity', function() {
var $row = $(this).closest('tr.item');
var qty = $(this).val();
var unit_subtotal = $row.attr('data-unit_subtotal');
var unit_subtotal_tax = $row.attr('data-unit_subtotal_tax');
var unit_total = $row.attr('data-unit_total');
var unit_total_tax = $row.attr('data-unit_total_tax');
var o_qty = $(this).attr('data-o_qty');
var subtotal = accounting.formatNumber( unit_subtotal * qty, 2, '' );
var tax = accounting.formatNumber( unit_subtotal_tax * qty, 2, '' );
var total = accounting.formatNumber( unit_total * qty, 2, '' );
var total_tax = accounting.formatNumber( unit_total_tax * qty, 2, '' );
$row.find('input.line_subtotal').val( subtotal );
$row.find('input.line_total').val( total );
$row.find('input.line_subtotal_tax').val( tax );
$row.find('input.line_tax').val( total_tax );
});
// When subtotal is changed, update the unit costs
$('#order_items_list').on( 'change', 'input.line_subtotal', function() {
var $row = $(this).closest('tr.item');
var $qty = $row.find('input.quantity');
var qty = $qty.val();
var value = ( qty ) ? accounting.toFixed( ( $(this).val() / qty ), 2 ) : 0;
$row.attr( 'data-unit_subtotal', value );
});
// When total is changed, update the unit costs + discount amount
$('#order_items_list').on( 'change', 'input.line_total', function() {
var $row = $(this).closest('tr.item');
var $qty = $row.find('input.quantity');
var qty = $qty.val();
var value = ( qty ) ? accounting.toFixed( ( $(this).val() / qty ), 2 ) : 0;
$row.attr( 'data-unit_total', value );
});
// When total is changed, update the unit costs + discount amount
$('#order_items_list').on( 'change', 'input.line_subtotal_tax', function() {
var $row = $(this).closest('tr.item');
var $qty = $row.find('input.quantity');
var qty = $qty.val();
var value = ( qty ) ? accounting.toFixed( ( $(this).val() / qty ), 2 ) : 0;
$row.attr( 'data-unit_subtotal_tax', value );
});
// When total is changed, update the unit costs + discount amount
$('#order_items_list').on( 'change', 'input.line_tax', function() {
var $row = $(this).closest('tr.item');
var $qty = $row.find('input.quantity');
var qty = $qty.val();
var value = ( qty ) ? accounting.toFixed( ( $(this).val() / qty ), 2 ) : 0;
$row.attr( 'data-unit_total_tax', value );
});
// Calculate totals
$('button.calc_line_taxes').live('click', function(){
// Block write panel
$('.woocommerce_order_items_wrapper').block({ message: null, overlayCSS: { background: '#fff url(' + woocommerce_writepanel_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
@ -191,8 +286,8 @@ jQuery( function($){
$.post( woocommerce_writepanel_params.ajax_url, data, function(response) {
result = jQuery.parseJSON( response );
$row.find('input.line_subtotal_tax').val( result.line_subtotal_tax );
$row.find('input.line_tax').val( result.line_tax );
$row.find('input.line_subtotal_tax').val( result.line_subtotal_tax ).change();
$row.find('input.line_tax').val( result.line_tax ).change();
if (idx == ($items.size() - 1)) {
$('.woocommerce_order_items_wrapper').unblock();
@ -227,9 +322,9 @@ jQuery( function($){
var line_totals = 0;
var cart_discount = 0;
var cart_tax = 0;
var order_shipping = parseFloat( $('#_order_shipping').val() );
var order_shipping_tax = parseFloat( $('#_order_shipping_tax').val() );
var order_discount = parseFloat( $('#_order_discount').val() );
var order_shipping = accounting.unformat( $('#_order_shipping').val() );
var order_shipping_tax = accounting.unformat( $('#_order_shipping_tax').val() );
var order_discount = accounting.unformat( $('#_order_discount').val() );
if ( ! order_shipping ) order_shipping = 0;
if ( ! order_shipping_tax ) order_shipping_tax = 0;
@ -237,42 +332,43 @@ jQuery( function($){
$('#order_items_list tr.item').each(function(){
var line_subtotal = parseFloat( $(this).find('input.line_subtotal').val() );
var line_subtotal_tax = parseFloat( $(this).find('input.line_subtotal_tax').val() );
var line_total = parseFloat( $(this).find('input.line_total').val() );
var line_tax = parseFloat( $(this).find('input.line_tax').val() );
var line_subtotal = accounting.unformat( $(this).find('input.line_subtotal').val() );
var line_subtotal_tax = accounting.unformat( $(this).find('input.line_subtotal_tax').val() );
var line_total = accounting.unformat( $(this).find('input.line_total').val() );
var line_tax = accounting.unformat( $(this).find('input.line_tax').val() );
if ( ! line_subtotal ) line_subtotal = 0;
if ( ! line_subtotal_tax ) line_subtotal_tax = 0;
if ( ! line_total ) line_total = 0;
if ( ! line_tax ) line_tax = 0;
line_subtotals = parseFloat( line_subtotals + line_subtotal );
line_subtotal_taxes = parseFloat( line_subtotal_taxes + line_subtotal_tax );
line_totals = parseFloat( line_totals + line_total );
line_subtotals = line_subtotals + line_subtotal;
line_subtotal_taxes = line_subtotal_taxes + line_subtotal_tax;
line_totals = line_totals + line_total;
if (woocommerce_writepanel_params.round_at_subtotal=='no') {
line_tax = parseFloat( line_tax.toFixed( 2 ) );
if ( woocommerce_writepanel_params.round_at_subtotal=='no' ) {
line_tax = accounting.toFixed( line_tax, 2 );
}
cart_tax = parseFloat( cart_tax + line_tax );
cart_tax = cart_tax + line_tax;
});
// Tax
if (woocommerce_writepanel_params.round_at_subtotal=='yes') {
cart_tax = parseFloat( cart_tax.toFixed( 2 ) );
cart_tax = accounting.toFixed( cart_tax, 2 );
}
// Cart discount
var cart_discount = ( (line_subtotals + line_subtotal_taxes) - (line_totals + cart_tax) );
if (cart_discount<0) cart_discount = 0;
cart_discount = cart_discount.toFixed( 2 );
if ( cart_discount < 0 ) cart_discount = 0;
cart_discount = accounting.toFixed( cart_discount, 2 );
// Total
var order_total = line_totals + cart_tax + order_shipping + order_shipping_tax - order_discount;
order_total = order_total.toFixed( 2 );
order_total = accounting.toFixed( order_total, 2 );
cart_tax = accounting.toFixed( cart_tax, 2 );
// Set fields
$('#_cart_discount').val( cart_discount );
$('#_order_tax').val( cart_tax );
@ -280,7 +376,6 @@ jQuery( function($){
// Since we currently cannot calc shipping from the backend, ditch the rows. They must be manually calculated.
$('#tax_rows').empty();
$('#woocommerce-order-totals').unblock();
} else {
@ -329,6 +424,8 @@ jQuery( function($){
$('select#add_item_id').trigger("liszt:updated");
$('table.woocommerce_order_items').unblock();
}
$('#order_items_list tr.new_row').trigger('init_row').removeClass('new_row');
});
size++;
@ -874,4 +971,9 @@ jQuery( function($){
}
});
});
/*!
* accounting.js v0.3.2, copyright 2011 Joss Crowcroft, MIT license, http://josscrowcroft.github.com/accounting.js
*/
(function(p,z){function q(a){return!!(""===a||a&&a.charCodeAt&&a.substr)}function m(a){return u?u(a):"[object Array]"===v.call(a)}function r(a){return"[object Object]"===v.call(a)}function s(a,b){var d,a=a||{},b=b||{};for(d in b)b.hasOwnProperty(d)&&null==a[d]&&(a[d]=b[d]);return a}function j(a,b,d){var c=[],e,h;if(!a)return c;if(w&&a.map===w)return a.map(b,d);for(e=0,h=a.length;e<h;e++)c[e]=b.call(d,a[e],e,a);return c}function n(a,b){a=Math.round(Math.abs(a));return isNaN(a)?b:a}function x(a){var b=c.settings.currency.format;"function"===typeof a&&(a=a());return q(a)&&a.match("%v")?{pos:a,neg:a.replace("-","").replace("%v","-%v"),zero:a}:!a||!a.pos||!a.pos.match("%v")?!q(b)?b:c.settings.currency.format={pos:b,neg:b.replace("%v","-%v"),zero:b}:a}var c={version:"0.3.2",settings:{currency:{symbol:"$",format:"%s%v",decimal:".",thousand:",",precision:2,grouping:3},number:{precision:0,grouping:3,thousand:",",decimal:"."}}},w=Array.prototype.map,u=Array.isArray,v=Object.prototype.toString,o=c.unformat=c.parse=function(a,b){if(m(a))return j(a,function(a){return o(a,b)});a=a||0;if("number"===typeof a)return a;var b=b||".",c=RegExp("[^0-9-"+b+"]",["g"]),c=parseFloat((""+a).replace(/\((.*)\)/,"-$1").replace(c,"").replace(b,"."));return!isNaN(c)?c:0},y=c.toFixed=function(a,b){var b=n(b,c.settings.number.precision),d=Math.pow(10,b);return(Math.round(c.unformat(a)*d)/d).toFixed(b)},t=c.formatNumber=function(a,b,d,i){if(m(a))return j(a,function(a){return t(a,b,d,i)});var a=o(a),e=s(r(b)?b:{precision:b,thousand:d,decimal:i},c.settings.number),h=n(e.precision),f=0>a?"-":"",g=parseInt(y(Math.abs(a||0),h),10)+"",l=3<g.length?g.length%3:0;return f+(l?g.substr(0,l)+e.thousand:"")+g.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+e.thousand)+(h?e.decimal+y(Math.abs(a),h).split(".")[1]:"")},A=c.formatMoney=function(a,b,d,i,e,h){if(m(a))return j(a,function(a){return A(a,b,d,i,e,h)});var a=o(a),f=s(r(b)?b:{symbol:b,precision:d,thousand:i,decimal:e,format:h},c.settings.currency),g=x(f.format);return(0<a?g.pos:0>a?g.neg:g.zero).replace("%s",f.symbol).replace("%v",t(Math.abs(a),n(f.precision),f.thousand,f.decimal))};c.formatColumn=function(a,b,d,i,e,h){if(!a)return[];var f=s(r(b)?b:{symbol:b,precision:d,thousand:i,decimal:e,format:h},c.settings.currency),g=x(f.format),l=g.pos.indexOf("%s")<g.pos.indexOf("%v")?!0:!1,k=0,a=j(a,function(a){if(m(a))return c.formatColumn(a,f);a=o(a);a=(0<a?g.pos:0>a?g.neg:g.zero).replace("%s",f.symbol).replace("%v",t(Math.abs(a),n(f.precision),f.thousand,f.decimal));if(a.length>k)k=a.length;return a});return j(a,function(a){return q(a)&&a.length<k?l?a.replace(f.symbol,f.symbol+Array(k-a.length+1).join(" ")):Array(k-a.length+1).join(" ")+a:a})};if("undefined"!==typeof exports){if("undefined"!==typeof module&&module.exports)exports=module.exports=c;exports.accounting=c}else"function"===typeof define&&define.amd?define([],function(){return c}):(c.noConflict=function(a){return function(){p.accounting=a;c.noConflict=z;return c}}(p.accounting),p.accounting=c)})(this);

File diff suppressed because one or more lines are too long

View File

@ -166,6 +166,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Templating - email-order-items.php change get_downloadable_file_url() to get_downloadable_file_urls() to support multiple files.
* Tweak - Added some calculations to the order page when manually entering rows. Also added accounting.js for more accurate rounding of floats.
* Tweak - Humanised order email subjects/headings
* Tweak - Cleaned up the tax settings.
* Tweak - If a PayPal prefix is changed, IPN requests break for all existing orders - fixed. new woocommerce_get_order_id_by_order_key() function added. Thanks Brent.

View File

@ -800,7 +800,7 @@ function woocommerce_add_order_item() {
$_product = new WC_Product_Variation( $post->ID );
endif;
?>
<tr class="item" rel="<?php echo $index; ?>">
<tr class="item new_row" rel="<?php echo $index; ?>">
<td class="thumb">
<a href="<?php echo esc_url( admin_url('post.php?post='. $_product->id .'&action=edit') ); ?>" class="tips" data-tip="<?php
echo '<strong>'.__('Product ID:', 'woocommerce').'</strong> '. $_product->id;
@ -850,7 +850,7 @@ function woocommerce_add_order_item() {
</td>
<td class="quantity" width="1%">
<input type="text" name="item_quantity[<?php echo $index; ?>]" placeholder="0" value="1" size="2" class="quantity" />
<input type="number" step="any" min="0" autocomplete="off" name="item_quantity[<?php echo $index; ?>]" placeholder="0" value="1" size="2" class="quantity" />
</td>
<td class="line_subtotal" width="1%">