Automattic\WooCommerce\StoreApi\Utilities

QuantityLimits::filter_value()protectedWC 1.0

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

{} Это метод класса: QuantityLimits{}

Возвращает

Разное.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->filter_value( $value, $value_type, $cart_item_or_product );
$value(int|null) (обязательный)
Value to filter.
$value_type(строка) (обязательный)
Type of value. Used for filter suffix.
$cart_item_or_product(\WC_Product|массив) (обязательный)
Either a cart item or a product instance.

Код QuantityLimits::filter_value() WC 6.8.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.
	 *
	 * @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 );
}