Compare with timestamp and remove start date once passed for sale products
Fixes #14753
This commit is contained in:
parent
52612435e3
commit
eedcdd97ba
|
@ -1413,11 +1413,11 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
if ( '' !== (string) $this->get_sale_price( $context ) && $this->get_regular_price( $context ) > $this->get_sale_price( $context ) ) {
|
||||
$on_sale = true;
|
||||
|
||||
if ( $this->get_date_on_sale_from( $context ) && $this->get_date_on_sale_from( $context )->getTimestamp() > time() ) {
|
||||
if ( $this->get_date_on_sale_from( $context ) && $this->get_date_on_sale_from( $context )->getTimestamp() > current_time( 'timestamp', true ) ) {
|
||||
$on_sale = false;
|
||||
}
|
||||
|
||||
if ( $this->get_date_on_sale_to( $context ) && $this->get_date_on_sale_to( $context )->getTimestamp() < time() ) {
|
||||
if ( $this->get_date_on_sale_to( $context ) && $this->get_date_on_sale_to( $context )->getTimestamp() < current_time( 'timestamp', true ) ) {
|
||||
$on_sale = false;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -420,6 +420,7 @@ function wc_scheduled_sales() {
|
|||
|
||||
if ( $sale_price ) {
|
||||
$product->set_price( $sale_price );
|
||||
$product->set_date_on_sale_from( '' );
|
||||
} else {
|
||||
$product->set_date_on_sale_to( '' );
|
||||
$product->set_date_on_sale_from( '' );
|
||||
|
|
Loading…
Reference in New Issue