Woocommerce 十进制数
你能帮我找到一种方法,在商业中使用十进制值,比如3.56来表示数量吗 在“计算价格数量”中,将数字转换为整数值,但我需要使用用户输入的值进行价格计算Woocommerce 十进制数,woocommerce,decimal,Woocommerce,Decimal,你能帮我找到一种方法,在商业中使用十进制值,比如3.56来表示数量吗 在“计算价格数量”中,将数字转换为整数值,但我需要使用用户输入的值进行价格计算 我正在使用woocommerce 2.2.8您必须为我使用的woocommerce的一些挂钩添加一些功能 // Add min value to the quantity field (default = 1) add_filter('woocommerce_quantity_input_min', 'min_decimal'); function
我正在使用woocommerce 2.2.8您必须为我使用的woocommerce的一些挂钩添加一些功能
// Add min value to the quantity field (default = 1)
add_filter('woocommerce_quantity_input_min', 'min_decimal');
function min_decimal($val) {
return 0.1;
}
// Add step value to the quantity field (default = 1)
add_filter('woocommerce_quantity_input_step', 'nsk_allow_decimal');
function nsk_allow_decimal($val) {
return 0.1;
}
// Removes the WooCommerce filter, that is validating the quantity to be an int
remove_filter('woocommerce_stock_amount', 'intval');
// Add a filter, that validates the quantity to be a float
add_filter('woocommerce_stock_amount', 'floatval');
我已经为这个功能编写了一个教程,附带了一些额外的修复,解释如下:我已经对一个现有的插件做了一些修改,允许使用十进制数。它被称为WooCommerce的数量和单位,可以在这里找到:
上次维护时间为2017年。