Iam trying to update woocommerce prices programmatically with with CRON.
I'm saving the new price to the _price, _regular_price and _sale_price post meta.
The post meta are correcty saved. But, somehow, the price is not updated.
This is a piece of the code:
function save_prices($post_ID){
$woo_prod = wc_get_product( $post_ID );
$price = some_function_to_get_the_price( $post_ID );
if($woo_prod->is_type( 'simple' )){
$woo_prod->update_meta_data( '_regular_price', $price );
$woo_prod->update_meta_data( '_sale_price', $price );
$woo_prod->update_meta_data( '_price', $price );
}
$woo_prod->save();
}
This function saves the post meta correctly, but woocommerce doesn't use these values for the product.
Anyone knows why this is happening?
Thanks