WordPress at Your Fingertips
function is not described

WC_REST_Products_V2_Controller::get_default_attributes() protected WC 1.0

Get default attributes.

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

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_default_attributes( $product );
$product(WC_Product) (required)
Product instance.

Code of WC_REST_Products_V2_Controller::get_default_attributes() WC 5.9.0

protected function get_default_attributes( $product ) {
	$default = array();

	if ( $product->is_type( 'variable' ) ) {
		foreach ( array_filter( (array) $product->get_default_attributes(), 'strlen' ) as $key => $value ) {
			if ( 0 === strpos( $key, 'pa_' ) ) {
				$default[] = array(
					'id'     => wc_attribute_taxonomy_id_by_name( $key ),
					'name'   => $this->get_attribute_taxonomy_name( $key, $product ),
					'option' => $value,
				);
			} else {
				$default[] = array(
					'id'     => 0,
					'name'   => $this->get_attribute_taxonomy_name( $key, $product ),
					'option' => $value,
				);
			}
		}
	}

	return $default;
}