Automattic\WooCommerce\StoreApi\Utilities

QuantityLimits::filter_boolean_valueprotectedWC 1.0

Get a boolean value while running it through a filter hook.

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

Возвращает

true|false.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->filter_boolean_value( $value, $value_type, $product, $cart_item );
$value(true|false) (обязательный)
Value to filter.
$value_type(строка) (обязательный)
Type of value. Used for filter suffix.
$product(WC_Product) (обязательный)
Product instance.
$cart_item(массив|null)
Optional cart item associated with the product.
По умолчанию: null

Код QuantityLimits::filter_boolean_value() WC 10.5.0

protected function filter_boolean_value( $value, string $value_type, \WC_Product $product, $cart_item = null ) {

	/**
	 * Filters boolean data for a cart item in Store API.
	 *
	 * The suffix of the hook will vary depending on the value being filtered. For example, 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 ) ? $filtered_value : (bool) $value;
}