Forum Replies Created

Viewing 16 replies (of 16 total)
  • dkdesignhawaii

    (@dkdesignhawaii)

    I needed to do a similar function showing the min to max range. Thanks to 303i for the jump start. Just needed a few extra lines of code. Hope this helps others.

    /**
    * Returns price range for grouped products
    **/
    function wc_grouped_price_html( $price, $product ) {
    	$all_prices = array();
    
    	foreach ( $product->get_children() as $child_id ) {
    		$all_prices[] = get_post_meta( $child_id, '_price', true );
    	}
    
    	if ( ! empty( $all_prices ) ) {
    		$max_price = max( $all_prices );
    		$min_price = min( $all_prices );
    	} else {
    		$max_price = '';$min_price = '';
    
    	}
    
    	$price = '<span class="from">' . _x('From: ', 'min_price', 'woocommerce') . woocommerce_price( $min_price ) .  _x(' to ', 'max_price', 'woocommerce') . ' </span>' . woocommerce_price( $max_price );
    
    	return $price;
    }
    add_filter( 'woocommerce_grouped_price_html', 'wc_grouped_price_html', 10, 2 );
Viewing 16 replies (of 16 total)