Woocommerce product query date_on_sale_from and date_on_sale_to not pulling any products


I’ve created the most simple product query:

$args     = [
    'date_on_sale_from' => '>=' . strtotime( 'December 09, 2022 12:00' ),
    'date_on_sale_to'   => '<=' . strtotime( 'December 11, 2022 12:00' ),
$products = wc_get_products( $args );

I would like to pull all the products that are scheduled to go on sale between 09th of December 2022 and scheduled to go off sale on 11th of December 2022.

Which products should be included? Any product that is scheduled to go on and off sale between those dates.

According to Woocommerce wc_get_products documentation this query should work and pull 1 product from my database but it doesn’t work unfortunately. Have anyone ever used this query parameter before?

enter image description here

Even if I remove the time from the strtotime() function it doesn’t work.

Any help would be appreciated.


odedta 2 months 2022-12-15T23:00:45-05:00 0 Answers 0 views 0

Leave an answer