woocommerce_quantity_input_min_admin
Filter to change the product quantity minimum in the order editor of the admin area.
In the 'edit' context the default is 0, floored at the item's current quantity when that is already negative (so orders created with negative quantities via the API remain editable). Since 11.2.0 the filter also runs with the 'add' context when products are added to an order.
Usage
add_filter( 'woocommerce_quantity_input_min_admin', 'wp_kama_woocommerce_quantity_input_min_admin_filter', 10, 3 );
/**
* Function for `woocommerce_quantity_input_min_admin` filter-hook.
*
* @param string $min The current minimum amount to be used in the quantity editor.
* @param WC_Product $product The product that is being edited.
* @param string $context The context in which the quantity editor is shown, 'edit', 'refund' or
* 'add'.
*
* @return string
*/
function wp_kama_woocommerce_quantity_input_min_admin_filter( $min, $product, $context ){
// filter...
return $min;
}
- $min(string)
- The current minimum amount to be used in the quantity editor.
- $product(WC_Product)
- The product that is being edited.
- $context(string)
- The context in which the quantity editor is shown, 'edit', 'refund' or 'add'.
Changelog
| Since 5.8.0 | Introduced. |
Where the hook is called
woocommerce_quantity_input_min_admin
woocommerce/includes/admin/meta-boxes/views/html-order-item.php 130
$min_refund = apply_filters( 'woocommerce_quantity_input_min_admin', '0', $product, 'refund' );
woocommerce/src/Internal/Admin/Orders/ItemQuantityLimits.php 46
$min = apply_filters( 'woocommerce_quantity_input_min_admin', $default, $product, 'edit' );
woocommerce/src/Internal/Admin/Orders/ItemQuantityLimits.php 67
$min = apply_filters( 'woocommerce_quantity_input_min_admin', '0', $product, 'add' );