How to change the default product quantity to 0 on the Wholesale Order Form

How to change the default product quantity to 0 on the Wholesale Order Form

By default, the Wholesale Order Form displays each product quantity as 1, unless you have set a Minimum Order Quantity to your products. The reasoning for this is it reduces the number of clicks or typing involved when ordering (since you can』t order 0 of something, it will be at least 1). The Order Form is all about speed ordering so this fits with that mindset.
However, we』ve received some requests from the past that they want to see the quantity starting from 0 instead. Unfortunately, we don』t support this feature as a setting but you can do it as a code snippet.
Using the custom snippet below will set the default value to 0, however, this only affects simple products on the Wholesale Order Form.
Please copy the snippet below and put it on your theme/child theme』s functions.php.

add_action('wwof_action_before_product_listing', function () {
add_filter('woocommerce_quantity_input_args', function ($input_args, $product) {
$input_args['input_value'] = 0;
return $input_args;
}, 10, 2);
});

add_filter('wwof_filter_product_item_quantity', function ($quantity_field, $product) {
$quantity_field = str_replace('input_value="1"', 'input_value="0"', $quantity_field);
return $quantity_field;
}, 10, 2);

If you』ll need further customization, I』d recommend asking for assistance from a developer and I』d suggest looking at Codeable.

發表回覆

您的郵箱地址不會被公開。 必填項已用 * 標註