Woocommerce小数

Dib*_*iba 3 decimal woocommerce

您能帮我找到一种在woocommerce中将3.56等十进制值用于数量的方法吗?

在计算价格数量中转换为整数值,但我需要使用用户输入的值进行价格计算

我正在使用woocommerce 2.2.8

msc*_*egg 6

您必须为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');
Run Code Online (Sandbox Code Playgroud)

我已经为此功能编写了一个教程,并提供了一些额外的修复程序,其解释如下:http : //codeontrack.com/use-decimal-in-quantity-fields-in-woocommerce-wordpress/