Skip to content

Instantly share code, notes, and snippets.

@projoomexperts
Created March 14, 2015 06:31
Show Gist options
  • Save projoomexperts/1135abf64f4ec21afcef to your computer and use it in GitHub Desktop.
Save projoomexperts/1135abf64f4ec21afcef to your computer and use it in GitHub Desktop.
Returns max price for grouped products woocommerce
/**
* Returns max price 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 );
} else {
$max_price = '';
}
$price = '<span class="from">' . _x('From:', 'max_price', 'woocommerce') . ' </span>' . woocommerce_price( $max_price );
return $price;
}
add_filter( 'woocommerce_grouped_price_html', 'wc_grouped_price_html', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment