WC_Product_Grouped::is_on_sale( string $context = 'view' )
Returns whether or not the product is on sale.
Description Description
Parameters Parameters
- $context
-
(Optional) What the value is for. Valid values are view and edit.
Default value: 'view'
Return Return
(bool)
Source Source
File: includes/class-wc-product-grouped.php
public function is_on_sale( $context = 'view' ) {
$children = array_filter( array_map( 'wc_get_product', $this->get_children( $context ) ), 'wc_products_array_filter_visible_grouped' );
$on_sale = false;
foreach ( $children as $child ) {
if ( $child->is_purchasable() && ! $child->has_child() && $child->is_on_sale() ) {
$on_sale = true;
break;
}
}
return 'view' === $context ? apply_filters( 'woocommerce_product_is_on_sale', $on_sale, $this ) : $on_sale;
}