WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Utilities

CartController::filter_request_data() protected WC 1.0

Filter data for add to cart requests.

{} It's a method of the class: CartController{}

Return

Array. Updated request array.

Usage

// protected - for code of main (parent) or child class
$result = $this->filter_request_data( $request );
$request(array) (required)
Add to cart request params.

Code of CartController::filter_request_data() WC 5.7.1

protected function filter_request_data( $request ) {
	$product_id   = $request['id'];
	$variation_id = 0;
	$product      = wc_get_product( $product_id );

	if ( $product->is_type( 'variation' ) ) {
		$product_id   = $product->get_parent_id();
		$variation_id = $product->get_id();
	}

	$request['cart_item_data'] = (array) apply_filters(
		'woocommerce_add_cart_item_data',
		$request['cart_item_data'],
		$product_id,
		$variation_id,
		$request['quantity']
	);

	if ( $product->is_sold_individually() ) {
		$request['quantity'] = apply_filters( 'woocommerce_add_to_cart_sold_individually_quantity', 1, $request['quantity'], $product_id, $variation_id, $request['cart_item_data'] );
	}

	return $request;
}