Skip to content

Commit

Permalink
If all variations are out of stock, maintain pricing.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Aug 11, 2015
1 parent 4a24aeb commit 42e9928
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
18 changes: 11 additions & 7 deletions includes/class-wc-product-variable.php
Expand Up @@ -154,14 +154,16 @@ public function get_children( $visible_only = false ) {
'key' => '_price',
'value' => '',
'compare' => '!=',
),
// Must be in stock
array(
)
);
// Must be in stock?
if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) {
$args['meta_query'][] = array(
'key' => '_stock_status',
'value' => 'instock',
'compare' => '=',
)
);
);
}
}
$this->children[ $key ] = get_posts( $args );
set_transient( $transient_name, $this->children, DAY_IN_SECONDS * 30 );
Expand Down Expand Up @@ -309,10 +311,12 @@ public function get_variation_prices( $display = false ) {
* @return string
*/
public function get_price_html( $price = '' ) {
if ( $this->get_price() === '' ) {
$prices = $this->get_variation_prices( true );

// No variations, or no active variation prices
if ( $this->get_price() === '' || empty( $prices['price'] ) ) {
$price = apply_filters( 'woocommerce_variable_empty_price_html', '', $this );
} else {
$prices = $this->get_variation_prices( true );
$min_price = current( $prices['price'] );
$max_price = end( $prices['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 );
Expand Down
3 changes: 3 additions & 0 deletions readme.txt
Expand Up @@ -159,6 +159,9 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc

== Changelog ==

* Tweak - If all variations are out of stock, maintain pricing.
* Tweak - If no variation prices are found, show no price label rather than free.

= 2.4.1 - 10/08/2015 =
* Fix - Tweaked the 2.4 upgrade routine to disable refund emails during update.
* Fix - Notices when calling get_shipping_classes().
Expand Down

0 comments on commit 42e9928

Please sign in to comment.