Automattic\WooCommerce\StoreApi\Utilities
QuantityLimits::filter_boolean_value()
Get a quantity for a product or cart item by running it through a filter hook.
Метод класса: QuantityLimits{}
Хуки из метода
Возвращает
true|false
.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->filter_boolean_value( $value, $value_type, $cart_item_or_product );
- $value(true|false) (обязательный)
- 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_boolean_value() QuantityLimits::filter boolean value WC 9.5.1
protected function filter_boolean_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 */ $filtered_value = apply_filters( "woocommerce_store_api_product_quantity_{$value_type}", $value, $product, $cart_item ); return is_bool( $filtered_value ) ? (bool) $filtered_value : $value; }