QuantityLimits::filter_value()protectedWC 1.0

Get a quantity for a product or cart item by running it through a filter hook.

Method of the class: QuantityLimits{}




// protected - for code of main (parent) or child class
$result = $this->filter_value( $value, $value_type, $cart_item_or_product );
$value(int|null) (required)
Value to filter.
$value_type(string) (required)
Type of value. Used for filter suffix.
$cart_item_or_product(\WC_Product|array) (required)
Either a cart item or a product instance.

QuantityLimits::filter_value() code WC 8.9.0

protected function filter_value( $value, string $value_type, $cart_item_or_product ) {
	$is_product = $cart_item_or_product instanceof \WC_Product;
	$product    = $is_product ? $cart_item_or_product : $cart_item_or_product['data'];
	$cart_item  = $is_product ? null : $cart_item_or_product;
	 * Filters the quantity minimum for a cart item in Store API. This allows extensions to control the minimum qty
	 * of items already within the cart.
	 * The suffix of the hook will vary depending on the value being filtered.
	 * For example, minimum, maximum, multiple_of, editable.
	 * @since 6.8.0
	 * @param mixed $value The value being filtered.
	 * @param \WC_Product $product The product object.
	 * @param array|null $cart_item The cart item if the product exists in the cart, or null.
	 * @return mixed
	return apply_filters( "woocommerce_store_api_product_quantity_{$value_type}", $value, $product, $cart_item );