Merge pull request #7021 from bryceadams/patch-7019

Add filter 'woocommerce_grouped_children_args'
This commit is contained in:
Mike Jolley 2014-12-30 14:47:39 +00:00
commit d09353c689
1 changed files with 17 additions and 5 deletions

View File

@ -10,7 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* Grouped products cannot be purchased - they are wrappers for other products.
*
* @class WC_Product_Grouped
* @version 2.0.0
* @version 2.3.0
* @package WooCommerce/Classes/Products
* @category Class
* @author WooThemes
@ -91,7 +91,17 @@ class WC_Product_Grouped extends WC_Product {
if ( empty( $this->children ) ) {
$this->children = get_posts( 'post_parent=' . $this->id . '&post_type=product&orderby=menu_order&order=ASC&fields=ids&post_status=publish&numberposts=-1' );
$args = apply_filters( 'woocommerce_grouped_children_args', array(
'post_parent' => $this->id,
'post_type' => 'product',
'orderby' => 'menu_order',
'order' => 'ASC',
'fields' => 'ids',
'post_status' => 'publish',
'numberposts' => -1,
) );
$this->children = get_posts( $args );
set_transient( $transient_name, $this->children, YEAR_IN_SECONDS );
}
@ -134,14 +144,16 @@ class WC_Product_Grouped extends WC_Product {
foreach ( $this->get_children() as $child_id ) {
$sale_price = get_post_meta( $child_id, '_sale_price', true );
if ( $sale_price !== "" && $sale_price >= 0 )
if ( $sale_price !== "" && $sale_price >= 0 ) {
return true;
}
}
} else {
if ( $this->sale_price && $this->sale_price == $this->price )
if ( $this->sale_price && $this->sale_price == $this->price ) {
return true;
}
}
return false;