Skip to content

Instantly share code, notes, and snippets.

@Mamaduka
Created February 27, 2012 10:24
Show Gist options
  • Save Mamaduka/1922991 to your computer and use it in GitHub Desktop.
Save Mamaduka/1922991 to your computer and use it in GitHub Desktop.
Get minimal price
<?php
/**
* Grouped price display
*/
function mamaduka_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 ) ) {
$min_price = min( $all_prices );
} else {
$min_price = '';
}
$price = '<span class="from">' . _x('Starting at:', 'min_price', 'woocommerce') . ' </span>' . woocommerce_price( $min_price );
return $price;
}
add_filter( 'woocommerce_grouped_price_html', 'mamaduka_wc_grouped_price_html', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment