Compare with timestamp and remove start date once passed for sale products

Fixes #14753
This commit is contained in:
Mike Jolley 2017-04-27 14:35:33 +01:00
parent 52612435e3
commit eedcdd97ba
2 changed files with 3 additions and 2 deletions

View File

@ -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 {

View File

@ -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( '' );