WC_Product_CSV_Exporter::get_column_value_grouped_products()protectedWC 3.1.0

Get grouped_products value.

Method of the class: WC_Product_CSV_Exporter{}

No Hooks.

Return

String.

Usage

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

Changelog

Since 3.1.0 Introduced.

WC_Product_CSV_Exporter::get_column_value_grouped_products() code WC 9.3.3

protected function get_column_value_grouped_products( $product ) {
	if ( 'grouped' !== $product->get_type() ) {
		return '';
	}

	$grouped_products = array();
	$child_ids        = $product->get_children( 'edit' );
	foreach ( $child_ids as $child_id ) {
		$child = wc_get_product( $child_id );
		if ( ! $child ) {
			continue;
		}

		$grouped_products[] = $child->get_sku( 'edit' ) ? $child->get_sku( 'edit' ) : 'id:' . $child_id;
	}
	return $this->implode_values( $grouped_products );
}