WordPress at Your Fingertips
function is not described

WC_Product_Grouped_Data_Store_CPT::update_prices_from_children() protected WC 1.0

Loop over child products and update the grouped product prices.

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

Hooks from the method
Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->update_prices_from_children( $product );
$product(WC_Product) (required) (passed by reference — &)
Product object.

Code of WC_Product_Grouped_Data_Store_CPT::update_prices_from_children() WC 5.6.0

protected function update_prices_from_children( &$product ) {
	$child_prices = array();
	foreach ( $product->get_children( 'edit' ) as $child_id ) {
		$child = wc_get_product( $child_id );
		if ( $child ) {
			$child_prices[] = $child->get_price( 'edit' );
		}
	}
	$child_prices = array_filter( $child_prices );
	delete_post_meta( $product->get_id(), '_price' );
	delete_post_meta( $product->get_id(), '_sale_price' );
	delete_post_meta( $product->get_id(), '_regular_price' );

	if ( ! empty( $child_prices ) ) {
		add_post_meta( $product->get_id(), '_price', min( $child_prices ) );
		add_post_meta( $product->get_id(), '_price', max( $child_prices ) );
	}

	$this->update_lookup_table( $product->get_id(), 'wc_product_meta_lookup' );

	/**
	 * Fire an action for this direct update so it can be detected by other code.
	 *
	 * @since 3.6
	 * @param int $product_id Product ID that was updated directly.
	 */
	do_action( 'woocommerce_updated_product_price', $product->get_id() );
}