Automattic\WooCommerce\Internal\Admin\Orders
ItemQuantityLimits::get_quantity_input_min
Get the minimum quantity accepted for an existing order item in the admin editor.
Method of the class: ItemQuantityLimits{}
Hooks from the method
Returns
string. Numeric string, filtered through woocommerce_quantity_input_min_admin.
Usage
$ItemQuantityLimits = new ItemQuantityLimits(); $ItemQuantityLimits->get_quantity_input_min( $item, $product ): string;
- $item(WC_Order_Item) (required)
- Line item being edited.
- $product(WC_Product|false|null)
- The item's product when the caller already resolved it; null to resolve it here.
Default:null
Changelog
| Since 11.2.0 | Introduced. |
ItemQuantityLimits::get_quantity_input_min() ItemQuantityLimits::get quantity input min code WC 11.2.1
public function get_quantity_input_min( WC_Order_Item $item, $product = null ): string {
if ( null === $product ) {
$product = $item instanceof WC_Order_Item_Product ? $item->get_product() : false;
}
$default = (string) min( 0, (float) $item->get_quantity() );
/**
* This filter is documented in includes/admin/meta-boxes/views/html-order-item.php
*
* @since 5.8.0
*/
$min = apply_filters( 'woocommerce_quantity_input_min_admin', $default, $product, 'edit' );
// A callback can return anything; fall back to the default on non-numeric values.
return is_numeric( $min ) ? (string) $min : $default;
}