WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Utilities

CartController::get_variable_product_attributes() protected WC 1.0

Get product attributes from the variable product (which may be the parent if the product object is a variation).

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

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_variable_product_attributes( $product );
$product(\WC_Product) (required)
Product being added to the cart.

Code of CartController::get_variable_product_attributes() WC 5.8.0

protected function get_variable_product_attributes( $product ) {
	if ( $product->is_type( 'variation' ) ) {
		$product = wc_get_product( $product->get_parent_id() );
	}

	if ( ! $product || 'trash' === $product->get_status() ) {
		throw new RouteException(
			'woocommerce_rest_cart_invalid_parent_product',
			__( 'This product cannot be added to the cart.', 'woocommerce' ),
			400
		);
	}

	return $product->get_attributes();
}