Created
March 14, 2015 06:31
-
-
Save projoomexperts/1135abf64f4ec21afcef to your computer and use it in GitHub Desktop.
Returns max price for grouped products woocommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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