woothemes/woocommerce — Issue #433: All variable and group products is labeled with 'Sale'
Author: hafizrahman
Created: 2011-12-30 09:05:10+00:00
State: open

Found an issue where all my grouped and variable products are labeled with the sale sticker despite them not having any sale price entered. After digging further here's what I found.

Line 463 in classes/product.class.php shows this:

```php
foreach ($this->get_children() as $child_id) :
$sale_price = get_post_meta( $child_id, '_sale_price', true );
if ( $sale_price >= 0 ) return true;
endforeach;
```

The problem is that in the wp_postmeta table, my grouped and variable products do have the meta_key '_sale_price', although their meta_value(s) are empty. This is probably set by woocommerce by default, I don't know.

So, since `$sale_price` is empty, `$sale_price >= 0` above returns true, hence the issue. I would suggest the following code to still allow for free sale price but ignores empty meta_values:

```php
foreach ($this->get_children() as $child_id) :
$sale_price = get_post_meta( $child_id, '_sale_price', true );
if ( !empty( $sale_price ) && $sale_price >= 0 ) return true;
endforeach;
```