admin管理员组文章数量:1332865
I have created a custom product field which is an auto-calculated field, which is saved to the meta data upon save. The calculation of the field is carried out live using javascript/jQuery. However, the calculation is not formating the figure to 2 decimal places:
jQuery(document).ready(function(jQuery) {
function compute() {
var a = jQuery('#_regular_price').val();
var b = jQuery('#_weight').val();
var total = a / b;
var totalformatted = total.toFixed(2);
jQuery('#shop_price_per_kg').val(totalformatted);
}
jQuery('#_regular_price, #_weight').change(compute);
});
What am I doing wrong in my code for why this is not working?
本文标签: woocommerce offtopicFormat number to 2 decimal places
版权声明:本文标题:woocommerce offtopic - Format number to 2 decimal places 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742289150a2447476.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论