Fix grouped product range display

Closes #11225
This commit is contained in:
Mike Jolley 2016-06-23 12:16:38 +01:00
parent a2b8352081
commit c7783bca24
2 changed files with 11 additions and 8 deletions

View File

@ -135,11 +135,11 @@ class WC_Product_Grouped extends WC_Product {
foreach ( $this->get_children() as $child_id ) {
$child = wc_get_product( $child_id );
$child_prices[] = 'incl' === $tax_display_mode ? $child->get_price_including_tax() : $child->get_price_excluding_tax();
if ( '' !== $child->get_price() ) {
$child_prices[] = 'incl' === $tax_display_mode ? $child->get_price_including_tax() : $child->get_price_excluding_tax();
}
}
$child_prices = array_unique( $child_prices );
if ( ! empty( $child_prices ) ) {
$min_price = min( $child_prices );
$max_price = max( $child_prices );
@ -148,13 +148,15 @@ class WC_Product_Grouped extends WC_Product {
$max_price = '';
}
if ( $min_price ) {
if ( $min_price === $max_price ) {
$price = wc_price( $min_price ) . $this->get_price_suffix();
if ( '' !== $min_price ) {
$price = $min_price !== $max_price ? sprintf( _x( '%1$s–%2$s', 'Price range: from-to', 'woocommerce' ), wc_price( $min_price ), wc_price( $max_price ) ) : wc_price( $min_price );
$is_free = $min_price == 0 && $max_price == 0;
if ( $is_free ) {
$price = apply_filters( 'woocommerce_grouped_free_price_html', __( 'Free!', 'woocommerce' ), $this );
} else {
$price = sprintf( _x( '%1$s–%2$s', 'Price range: from-to', 'woocommerce' ), wc_price( $min_price ), wc_price( $max_price ) ) . $this->get_price_suffix();
$price = apply_filters( 'woocommerce_grouped_price_html', $price . $this->get_price_suffix(), $this );
}
$price = apply_filters( 'woocommerce_grouped_price_html', $price, $this );
} else {
$price = apply_filters( 'woocommerce_grouped_empty_price_html', '', $this );
}

View File

@ -171,6 +171,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Fix - Convert ellipsis to three periods when saving postcodes.
* Fix - Prevent get_terms returning duplicates.
* Fix - Removed non-existent country (Netherlands Antilles) from https://en.wikipedia.org/wiki/ISO_3166-1.
* Fix - Grouped product range display when child is free.
* Tweak - Made customer pay link display if order needs_payment() rather than checking pending status.
* Tweak - Zones - Wording clarifications.
* Tweak - Zones - Match zones with postcodes but no country.