WC_Product_Variable::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. What the value is for. Valid values are view and edit.

Default value: 'view'


Top ↑

Return Return

(bool)


Top ↑

Source Source

File: includes/class-wc-product-variable.php

	public function is_on_sale( $context = 'view' ) {
		$prices  = $this->get_variation_prices();
		$on_sale = $prices['regular_price'] !== $prices['sale_price'] && $prices['sale_price'] === $prices['price'];

		return 'view' === $context ? apply_filters( 'woocommerce_product_is_on_sale', $on_sale, $this ) : $on_sale;
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.