Automattic\WooCommerce\StoreApi\Utilities

QuantityLimits::filter_boolean_valueprotectedWC 1.0

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

Method of the class: QuantityLimits{}

Returns

true|false.

Usage

// protected - for code of main (parent) or child class
$result = $this->filter_boolean_value( $value, $value_type, $product, $cart_item );
$value(true|false) (required)
Value to filter.
$value_type(string) (required)
Type of value. Used for filter suffix.
$product(WC_Product) (required)
Product instance.
$cart_item(array|null)
Optional cart item associated with the product.
Default: null

QuantityLimits::filter_boolean_value() code WC 10.9.1

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;
}