I have a php cron job that is updating product information from a 3rd party vendor. These changes can be price, sale price, stock, etc.
I have everything running except when I go to put a product on sale via the following code:
update_post_meta( $product_id, '_sale_price', $sale_price );
update_post_meta( $product_id, '_price', $sale_price );
the product is updated correctly and shows the sale price in the product on the website and the product admin. When I go to use one of the shortcodes for woocommerce to display products on sale it does NOT pull back what was updated via the above code, ONLY if it was done through the admin panel.
[products limit="24" columns="4" on_sale="true" ]
So my code is not doing something woocommerce does, but I have no idea what it is I am missing. My only fix so far I have found is to remove the sale price in the admin panel->save and then add it back->and save again. Since there are 18,000+ variations on 3,000+ products this is not something that can be done by hand.
As an aside: I had this problem with WP all import too when we imported vis csv file feeds.
Any ideas or thoughts would be helpful.
Thanks!